Beispiel #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $adventure = Adventure::find($id);
     $comments = Comment::where('adventure_id', $id)->get();
     $pictures = Picture::where('adventure_id', $id)->get();
     return view('adventures.show', compact('adventure', 'comments'))->with('pictures', $pictures);
 }
Beispiel #2
0
 /**
  * returns Picture with prev and next Picture as attributes for single navigation
  *
  * @param $id
  * @return mixed
  */
 public static function getSinglePic($id)
 {
     $pic = Picture::findOrFail($id);
     $all = Picture::where('trip_entry_id', $pic->trip_entry_id)->orderBy('id')->get();
     $index = $all->search($pic);
     $count = $all->count();
     if ($index != 0) {
         $prev = $all[$index - 1];
         $pic->prev = $prev;
     }
     if ($index + 1 != $count) {
         $next = $all[$index + 1];
         $pic->next = $next;
     }
     return $pic;
 }
 public function postPicture(Request $request)
 {
     $this->validate($request, ['description' => 'required|max:255', 'photo' => 'required|mimes:jpeg,gif,png']);
     $date = Carbon::now();
     $filename = Input::file('photo')->getClientOriginalName();
     $rand = rand(11111, 99999);
     Image::make(Input::file('photo'))->save('img/users/' . $rand . '-' . $filename);
     $count = Picture::where('user_id', Auth::user()->id)->count();
     if ($count == 5) {
         $count = Picture::where('user_id', Auth::user()->id)->orderBy('created_at', 'asc')->take(1)->delete();
     }
     $inputData = $request->all();
     $img = new Picture();
     $img->picture_url = '/img/users/' . $rand . '-' . $filename;
     $img->description = $inputData['description'];
     $img->isDish = 0;
     $img->user_id = Auth::user()->id;
     $img->save();
     return redirect()->route('dashboard')->withSuccess('succesfully added a picture');
 }
 public function getDefaultPicture($type)
 {
     return Picture::where(['defaultpic' => 1, 'type' => $type])->get();
 }
 /**
  * Find pictures by category and send them back in json-format.
  *
  * parameter:   http-request $request
  * returns:     json-response
  */
 public function findByCategory(Request $request)
 {
     // Pictures are ordered from most liked to least liked by default.
     $pictures = Picture::where('category', $request->category)->orderBy('likes', 'desc')->get();
     return response()->json($pictures);
 }
 public function editPictures($id)
 {
     $gallery = Gallery::findOrFail($id);
     $pictures = Picture::where('gallery_id', $id)->get();
     $title = 'Administration des photos de la galerie "' . $gallery->name_fr . '"';
     return view('admin.galleries.editPictures', compact('title', 'gallery', 'pictures'));
 }
 public function getProfile($id)
 {
     $user = User::findOrFail($id);
     $images = Picture::where('user_id', '=', $id)->where('isDish', '=', false)->orderBy('id', 'desc')->take(5)->get();
     $time = explode("-", $user->dateOfBirth);
     $dt = Carbon::createFromDate($time[0], $time[1], $time[2], 'Europe/Brussels');
     $now = Carbon::today();
     $age = $now->diffInYears($dt);
     // echo $age;
     // $profile->age =$age;
     $data = ['profile' => $user, 'images' => $images, 'age' => $age];
     return View('profile')->with($data);
 }
 public function get($filename)
 {
     $picture = Picture::where('filename', '=', $filename)->firstOrFail();
     $file = Storage::disk('local')->get($picture->filename);
     return (new Response($file, 200))->header('Content-Type', $picture->mime);
 }