Example #1
0
 public function getDetail($id)
 {
     $onePiece = $this->onePiece();
     $art = Art::where('id', $id)->where('sold', 0)->firstOrFail();
     $headpicture = Pictures::Where('art_id', $art->id)->first();
     $pictures = Pictures::Where('art_id', $art->id)->skip(1)->take(3)->get();
     $nrbids = Bid::where('art_id', $art->id)->count();
     if ($nrbids != 1) {
         $nrbids .= " " . trans('detail.bid');
     } else {
         $nrbids .= " " . trans('detail.singleBid');
     }
     $now = Carbon::now();
     $dt = new \DateTime($art->ending);
     $duration = $dt->diff($now);
     $related = Art::where('arts.style_id', $art->style_id)->where('sold', 0)->join('pictures', 'pictures.art_id', '=', 'arts.id')->where('ending', '>', $now)->orderBy(\DB::raw('RAND()'))->take(4)->get();
     foreach ($related as $rel) {
         $dt = new \DateTime($art->ending);
         $relDuration[] = $dt->diff($now);
     }
     $watchlist = watchlist::where('art_id', $id)->where('user_id', Auth::user()->id)->first();
     $added = new \DateTime($art->created_at);
     $added = $added->format('F j Y');
     $shortdesc = implode(' ', array_slice(explode(' ', $art->description), 0, 20)) . "...";
     //->format('l jS \\of F Y h:i:s A');         // Thursday 25th of December 1975 02:15:16 PM
     return View('art.detail', compact('shortdesc', 'added', 'art', 'headpicture', 'pictures', 'watchlist', 'nrbids', 'duration', 'onePiece', 'related', 'relDuration'));
 }
Example #2
0
 /**
  * Permet d'aficher la page d'ajout de photo
  *
  * @param  int  $id
  * @return View
  */
 public function photosAdd($id, PhotosRequest $photosrequest)
 {
     $directory = '/uploads/photos/' . $id;
     if (!File::exists(public_path() . $directory)) {
         File::makeDirectory(public_path() . $directory, 0775, true);
     }
     $files = $photosrequest->file('file');
     foreach ($files as $file) {
         $name = Auth::id() . '_' . $id . '_' . str_slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME), '-') . rand(1000, 9999);
         $name_thumb = 'thumb_' . $name;
         $name_thumb2 = 'thumb2_' . $name;
         $file_path = $name . '.' . $file->getClientOriginalExtension();
         $img = Image::make($file);
         $img->interlace();
         $img->save('uploads/photos/' . $id . '/' . $name . '.' . $file->getClientOriginalExtension());
         $img->fit(200, 200);
         $img->save('uploads/photos/' . $id . '/' . $name_thumb . '.' . $file->getClientOriginalExtension());
         $img = Image::make($file);
         $img->resize(180, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save('uploads/photos/' . $id . '/' . $name_thumb2 . '.' . $file->getClientOriginalExtension());
         $picture = new Pictures();
         $picture->name = $file_path;
         $picture->directory = $directory;
         $picture->albums_id = $id;
         $picture->save();
     }
     Session::flash('success', "Vos photos on été ajoutées à l'album");
     return redirect('/albums/' . $id);
 }