當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::whereRaw方法代碼示例

本文整理匯總了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!');
 }
開發者ID:phumaster,項目名稱:uploadImage,代碼行數:33,代碼來源:ImageController.php


注:本文中的app\Image::whereRaw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。