本文整理匯總了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);
}