Ejemplo n.º 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'));
 }