Пример #1
0
 public function postDeletePhoto(DeletePhotoRequest $request)
 {
     $photo = Photo::find($request->get('id'));
     $this->deleteImage($photo->path);
     $photo->delete();
     return redirect("validated/photos?id={$photo->album_id}")->with(['deleted' => 'The photo was deleted']);
 }
Пример #2
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $id = $this->get('id');
     $photo = Photo::find($id);
     $album = Auth::user()->albums()->find($photo->album_id);
     return $album ? true : false;
 }
Пример #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $id = $request->segment(4);
     $photo = Photo::find($id);
     if ($photo == null) {
         return redirect('/validated/albums');
     }
     return $next($request);
 }