public function search(Request $request, $search, $sort = 'new', $class = null, $filter = null) { //check if something was searched if ($search == "") { return redirect()->route('home')->withErrors(['please fill in the searchbox']); } //get all FAQ found on search $FAQ = FAQ::where('question', 'like', '%' . $search . '%')->orwhere('answer', 'like', '%' . $search . '%')->get(); //get all auctions found on search $artOutput = Art::selectRaw('art.*, max(bids.price) as highest_bid, count(bids.art_id) AS `count`')->leftJoin('bids', 'bids.art_id', '=', 'art.id')->groupBy('art.id')->where(function ($query) use($search) { $query->where('description_nl', 'like', '%' . $search . '%')->orWhere('description_en', 'like', '%' . $search . '%')->orWhere('title', 'like', '%' . $search . '%'); })->where('art.processed', '0'); //add filters to art $auctions = $this->add_filters($artOutput, $sort, $class, $filter); $auctions = $auctions->groupBy('bids.art_id')->paginate(9); $data['search'] = $search; $data['FAQ'] = $FAQ; $data['art'] = $auctions; $data['sort'] = $sort; $data['route'] = 'art.search'; return View('search')->with($data); }