public function search(Request $request)
 {
     $search = $request->search;
     $arts = Auction::where('title', 'like', '%' . $search . '%')->orWhere('artist', 'like', '%' . $search . '%')->orWhere('artist', 'like', '%' . $search . '%')->orWhere('description', 'like', '%' . $search . '%')->orderBy('end_date')->paginate(8);
     $styles = Auctionstyle::all();
     return view('overzicht', compact('arts', 'styles', 'search'));
 }
 public function overzicht(Request $request)
 {
     //        sort data
     if ($request->session()->has('order')) {
         $order = $request->session()->get('order');
         $orderby = $order['by'];
         $orderdirection = $order['direction'];
     } else {
         $orderby = 'end_date';
         $orderdirection = 'asc';
     }
     if ($orderby == 'popular') {
         if ($request->session()->has('filter')) {
             $arts = Auction::select(DB::raw('auctions.*, count(*) as `totalbids`'))->join('bids', 'auctions.id', '=', 'bids.auction_id')->groupBy('auction_id')->orderBy('totalbids', 'desc')->where('active', '=', true)->where('end_date', '>', Carbon::now())->paginate(8);
         } else {
             /* no filter */
             $arts = Auction::select(DB::raw('auctions.*, count(*) as `totalbids`'))->join('bids', 'auctions.id', '=', 'bids.auction_id')->groupBy('auction_id')->orderBy('totalbids', 'desc')->where('active', '=', true)->where('end_date', '>', Carbon::now())->paginate(8);
         }
     } else {
         if ($request->session()->has('filter')) {
             $filter = $request->session()->get('filter');
             $query = Auction::query();
             $query->orderBy($orderby, $orderdirection);
             $query->where('end_date', '>', Carbon::now());
             $query->where('active', '=', true);
             $query->paginate(8);
             if (isset($filter['price']['on'])) {
                 if ($filter['price']['on'] == true) {
                     $query->whereBetween('price_buy', array($filter['price']['bottom'], $filter['price']['top']));
                 }
             }
             if (isset($filter['era']['on'])) {
                 if ($filter['era']['on'] == true) {
                     $query->whereBetween('year', array($filter['era']['bottom'], $filter['era']['top']));
                 }
             }
             if (isset($filter['style']['on'])) {
                 if ($filter['style'] == true) {
                     $query->where('auctionstyle_id', '=', $filter['style']['bottom']);
                 }
             }
             $arts = $query->get();
         } else {
             /* no filter */
             $arts = Auction::orderBy($orderby, $orderdirection)->where('end_date', '>', Carbon::now())->where('active', '=', true)->paginate(8);
         }
     }
     // get styles
     $styles = Auctionstyle::all();
     return view('overzicht', compact('arts', 'styles'));
 }
 public function add()
 {
     $styles = Auctionstyle::lists('name', 'id');
     return view('auction_add', compact('styles'));
 }