本文整理汇总了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!');
}