本文整理匯總了PHP中app\Image::whereRaw方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::whereRaw方法的具體用法?PHP Image::whereRaw怎麽用?PHP Image::whereRaw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Image
的用法示例。
在下文中一共展示了Image::whereRaw方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $user, $id)
{
$a = Auth::user();
$data = Image::find($id);
$user_id = $a->id;
$auth = substr(md5($a->id . $a->email), 0, 10);
$resource = $request->except(['_token', 'image', '_method']);
if ($request->hasFile('image')) {
$file = $request->file('image');
$imageName = date('d-m-Y_h-i-s') . '_' . $user_id . '_' . $file->getClientOriginalName();
$path = $this->path . '/' . $user_id . '_' . $auth;
$destination = $path;
$folder = public_path() . '/' . $path;
if (!file_exists($folder)) {
mkdir($folder);
}
$image = ['image_name' => $imageName, 'image_size' => $file->getSize(), 'fullsize_url' => $path . '/' . $imageName];
if (unlink(public_path() . '/' . $data->fullsize_url) && $file->move($destination, $imageName) && Image::whereRaw("`id` = {$id} AND `user_id` = {$user_id}")->update(array_merge($resource, $image))) {
return redirect()->route('photo.index', $user)->with(['message' => 'Your image has been update!']);
}
}
if (Image::whereRaw("`id` = {$id} AND `user_id` = {$user_id}")->update($resource)) {
return redirect()->route('photo.index', $user)->with(['message' => 'Your image has been update!']);
}
return redirect()->route('photo.edit', [$user, $id])->withErrors('Unexpected error!');
}