本文整理汇总了PHP中ImageHelper::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageHelper::create方法的具体用法?PHP ImageHelper::create怎么用?PHP ImageHelper::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageHelper
的用法示例。
在下文中一共展示了ImageHelper::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
if ($request->id == 51) {
return response()->json(['demo' => "You aren't allowed to edit the demo user"], 422);
}
$this->validate($request, ['name' => 'required|min:3|max:20', 'email' => 'required|email|unique:users,email,' . $id, 'oldpassword' => 'required', 'repassword' => 'required_with:password|same:password']);
if ($request->password && strlen($request->password) < 6) {
return response()->json(["password" => "Your password must be at least 6 characters"], 422);
}
$user = User::find($id);
if (Hash::check($request->oldpassword, $user->password)) {
$data = $request->all();
if ($request->password) {
$data['password'] = bcrypt($request->password);
}
if ($request->file) {
$validate = ImageHelper::validate($request->file, 2000000);
if (!$validate['success']) {
return response()->json([$validate['message']], 422);
}
$image = ImageHelper::create($request->file, 600, 'admin/images/users/');
$data['image'] = $image['filename'];
}
$user->update($data);
$user->UserRoles()->update(['role' => $data['user_roles']['role']]);
return response()->json(['message' => 'User successfully updated']);
}
return response()->json(['oldpassword' => 'Old password is not correct'], 422);
}