예제 #1
0
 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);
 }
예제 #2
0
 /**
  * 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);
 }
 /**
  * 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]);
 }
예제 #4
0
 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');
 }
예제 #5
0
 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);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $photo = Photo::findOrFail($id)->delete();
     return back();
 }
 /**
  * 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]);
 }
예제 #10
0
 public function destory($id)
 {
     Photo::findOrFail($id)->delete();
     return back();
 }
예제 #11
0
 /**
  * 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();
 }
예제 #12
0
 public function destroy($id)
 {
     Photo::findOrFail($id)->delete();
     return redirect()->back();
 }
예제 #13
0
 public function destroy($id)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     Photo::findOrFail($id)->delete();
     return redirect()->back();
 }
예제 #14
0
 public function destroyPhoto($id)
 {
     Photo::findOrFail($id)->delete;
     return view('flyers.show', compact('flyer'));
 }
예제 #15
0
 /**
  * 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();
 }
예제 #16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $photo = Photo::findOrFail($id);
     $id = $photo->id;
     $photo->delete();
     flashMessage("Photo with ID {$id} has been deleted.", "alert-success");
     return redirect('photos/list');
 }