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']); }
/** * 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); if ($album) { return true; } return false; }