当前位置: 首页>>代码示例>>PHP>>正文


PHP Photo::findOrFail方法代码示例

本文整理汇总了PHP中app\Photo::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::findOrFail方法的具体用法?PHP Photo::findOrFail怎么用?PHP Photo::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Photo的用法示例。


在下文中一共展示了Photo::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 public function delete(Request $request, $id)
 {
     $photo = Photo::findOrFail($id);
     $photo->removeThumbnail();
     unlink($photo->path);
     $albumId = $photo->album_id;
     $photo->delete();
     return redirect('/album/' . $albumId);
 }
开发者ID:pitchinnate,项目名称:photoshare,代码行数:9,代码来源:PhotoController.php

示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($albumId, $id)
 {
     $photo = Photo::findOrFail($id);
     try {
         File::delete(public_path() . '/uploads/photos/' . $photo->photo);
         $photo->destroy($id);
     } catch (Exception $e) {
         App::abort(404);
     }
     return Redirect::route('admin.photos.show', $albumId);
 }
开发者ID:nikajorjika,项目名称:gamoiwere.ge,代码行数:17,代码来源:PhotoController.php

示例3: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($id)
 {
     $photo = Photo::findOrFail($id);
     $photoSrc = '/photo_files/normal/' . $photo->file_name;
     $photoId = $photo->id;
     $galleryList = array();
     $galleries = Gallery::orderBy('name', 'asc')->get();
     foreach ($galleries as $gallery) {
         $galleryList[strval($gallery->id)] = $gallery->name;
     }
     return view('submissions.create')->with(['photoSrc' => $photoSrc, 'photoId' => $photoId, 'galleryList' => $galleryList, 'galleryId' => null]);
 }
开发者ID:BobHumphrey,项目名称:tumblr-photos,代码行数:17,代码来源:SubmissionsController.php

示例4: actionCreate

 public function actionCreate(Requests\CreateLikeRequest $request)
 {
     // Create a new model instance and populate it with the request.
     $like = new Like($request->all());
     // Find in the database the photo sent with the request.
     $photo = Photo::findOrFail($request->input('photo_id'));
     // Attach the like to the photo.
     $like = $photo->likes()->save($like);
     // Save the like in the database.
     Auth::user()->likes()->save($like);
     // Redirect.
     return redirect('/photos');
 }
开发者ID:JCStraw3,项目名称:photos,代码行数:13,代码来源:LikeController.php

示例5: actionCreate

 public function actionCreate(Requests\CreateCommentRequest $request)
 {
     // Create a new model instance and populate it with the request.
     $comment = new Comment($request->all());
     // Find in the database the photo sent with the request.
     $photo = Photo::findOrFail($request->input('photo_id'));
     // Attach the comment to the photo.
     $comment = $photo->comments()->save($comment);
     // Save the comment in the database.
     Auth::user()->comments()->save($comment);
     // Redirect with flash message.
     \Session::flash('flash_message', 'You have successfully commented on a photo.');
     return json_encode($comment);
 }
开发者ID:JCStraw3,项目名称:photos,代码行数:14,代码来源:CommentController.php

示例6: handle

 public function handle(Request $request, Closure $next, $param)
 {
     if ($request->user()->is_admin == 0) {
         if ($param == 'album') {
             $access = $request->user()->hasAccess($request->id);
         } else {
             $photo = Photo::findOrFail($request->id);
             $access = $request->user()->hasAccess($photo->album_id);
         }
         if (!$access) {
             return new Response('You do not have access to this album or photo', 403);
         }
     }
     return $next($request);
 }
开发者ID:pitchinnate,项目名称:photoshare,代码行数:15,代码来源:Access.php

示例7: viewUpdate

 public function viewUpdate($id)
 {
     // Set logged in user to a variable.
     $authUser = Auth::user();
     // Find photo in database.
     $photo = Photo::findOrFail($id);
     // Find the photo's user in database, set to variable.
     $userId = $photo->user_id;
     $user = User::findOrFail($userId);
     // If logged in user does not own photo, return error.
     if ($authUser->id !== $user->id) {
         return view('errors.403');
     }
     // Find all tags in database.
     $tags = Tag::all();
     // Return view with variables.
     return view('photos.viewUpdate')->with('photo', $photo)->with('tags', $tags)->with('authUser', $authUser);
 }
开发者ID:JCStraw3,项目名称:photos,代码行数:18,代码来源:PhotoController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $photo = Photo::findOrFail($id)->delete();
     return back();
 }
开发者ID:ayimdomnic,项目名称:project-flyer,代码行数:11,代码来源:PhotosController.php

示例9: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     /*
      * Find the photo we want to edit
      */
     $photo = Photo::findOrFail($id);
     return view('dashboard.photos.edit', ['photo' => $photo]);
 }
开发者ID:Alxmerino,项目名称:portfolio-16v.laravel,代码行数:15,代码来源:PhotoController.php

示例10: destory

 public function destory($id)
 {
     Photo::findOrFail($id)->delete();
     return back();
 }
开发者ID:najibu,项目名称:project-flyer,代码行数:5,代码来源:PhotosController.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //$file_path = '/var/www/html/storage';
     $file_path = 'storage/';
     $photo = Photo::findOrFail($id);
     if (\Auth::user() == $photo->user) {
         unlink($file_path . '/thumbnail_l/' . $photo->filename);
         unlink($file_path . '/thumbnail_s/' . $photo->filename);
         unlink($file_path . '/photo/' . $photo->filename);
         $photo->delete();
     } else {
         abort(403, 'Unauthorized action.');
     }
     return back();
 }
开发者ID:ynniswitrin,项目名称:8A-Fotos,代码行数:21,代码来源:PhotoController.php

示例12: destroy

 public function destroy($id)
 {
     Photo::findOrFail($id)->delete();
     return redirect()->back();
 }
开发者ID:albarincon,项目名称:projectflyer,代码行数:5,代码来源:PhotosController.php

示例13: destroy

 public function destroy($id)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     Photo::findOrFail($id)->delete();
     return redirect()->back();
 }
开发者ID:mhv745,项目名称:project-flyer,代码行数:6,代码来源:FlyerPhotosController.php

示例14: destroyPhoto

 public function destroyPhoto($id)
 {
     Photo::findOrFail($id)->delete;
     return view('flyers.show', compact('flyer'));
 }
开发者ID:Andriy-Kulak,项目名称:ProjectFlyer,代码行数:5,代码来源:FlyersController.php

示例15: destroy

 /**
  * Remove the specified Photo
  *
  * @param $zip
  * @param $street
  * @param AddPhotoRequest|Request $request
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, AddPhotoRequest $request)
 {
     Photo::findOrFail($id)->delete();
     return back();
 }
开发者ID:buys-fran,项目名称:project-flyer,代码行数:13,代码来源:PhotosController.php


注:本文中的app\Photo::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。