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


PHP Image::findOrFail方法代碼示例

本文整理匯總了PHP中app\Image::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::findOrFail方法的具體用法?PHP Image::findOrFail怎麽用?PHP Image::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Image的用法示例。


在下文中一共展示了Image::findOrFail方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $image = Image::findOrFail($id);
     $image->delete();
     flash()->warning('Gambar telah dihapus!');
     return redirect('/dashboard/images');
 }
開發者ID:kobeuu,項目名稱:bpb-sf,代碼行數:13,代碼來源:ImagesController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['original_name' => 'required', 'filename' => 'required']);
     $image = Image::findOrFail($id);
     $image->update($request->all());
     Session::flash('flash_message', 'Image updated!');
     return redirect('admin/image');
 }
開發者ID:wilderguzman,項目名稱:lugrawibe,代碼行數:15,代碼來源:ImageController.php

示例3: saveImageAlt

 private static function saveImageAlt($image_id, $alt)
 {
     if (empty($alt)) {
         return;
     }
     $Image = \App\Image::findOrFail($image_id);
     $Image->imgalt = $alt;
     $Image->save();
     return;
 }
開發者ID:brevig907,項目名稱:apt,代碼行數:10,代碼來源:DashboardController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     $image = Image::findOrFail($id);
     ImageRelease::where('image_id', $id)->delete();
     ImageTrack::where('image_id', $id)->delete();
     ArtistImage::where('image_id', $id)->delete();
     if (Storage::disk('images')->has($image->path)) {
         Storage::disk('images')->delete($image->path);
     }
     $image->delete();
     return redirect()->route('home.index')->with('alert-success', [trans('htmusic.deleted')]);
 }
開發者ID:milutinm,項目名稱:htmusic,代碼行數:21,代碼來源:ImageController.php

示例5: destroy

 public function destroy($id)
 {
     Image::findOrFail($id)->delete();
     session()->flash('flash_message', 'Photo Deleted');
     return redirect('/gallery');
 }
開發者ID:mathewsandi,項目名稱:PennasSite,代碼行數:6,代碼來源:UploadController.php

示例6: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Image::findOrFail($id)->delete();
     return trans('images.removed');
 }
開發者ID:Vatia13,項目名稱:megaportal,代碼行數:11,代碼來源:ImagesController.php

示例7: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $img = Image::findOrFail($id);
     // base path
     $base_path = public_path() . "/images/";
     // remove from file system
     // remove thumb
     unlink($base_path . "thumbs/{$img->path}");
     // remove image
     unlink($base_path . "{$img->path}");
     // remove from database
     $img->delete();
 }
開發者ID:john-ko,項目名稱:sharonypark,代碼行數:19,代碼來源:ImageController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $image = Image::findOrFail($id);
     $image->delete();
     Session::flash('flash_message', 'Image successfully deleted!');
     return redirect()->route('images.index');
 }
開發者ID:Tasmia09,項目名稱:BakeACake,代碼行數:13,代碼來源:ImagesController.php

示例9: postChange

 public function postChange(Request $request)
 {
     $input = $request->all();
     $image = Image::findOrFail($input['id']);
     $file = Input::file('images');
     $rules = array('file' => 'image|max:3000');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         Session::flash('flash_message', 'Ошибка записи файлов!');
         return redirect()->back();
     } else {
         $destinationPath = 'uploads/images/';
         $filename = str_random(15) . '_' . substr($file->getClientOriginalName(), 0, strpos($file->getClientOriginalName(), ".")) . '.' . $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename);
         $image->path = $destinationPath . $filename;
         $image->save();
         unlink($input['path']);
         Session::flash('flash_message', 'Картинка успешно изменена!');
     }
     return redirect()->back();
 }
開發者ID:vitaloldos,項目名稱:shop,代碼行數:21,代碼來源:ImagesController.php

示例10: findOrFail

 public function findOrFail($id)
 {
     return Image::findOrFail($id);
 }
開發者ID:jeroenhekihenk,項目名稱:video-platform,代碼行數:4,代碼來源:ImagesRepository.php


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