public function listQuizes() { $search = Input::get('search', null); $sortOptions = self::processSort(); //Uses normal left join than "with('stats')" to be able to sort by shareRate $quizesQuery = Quiz::joinStats()->orderBy($sortOptions['sort'], $sortOptions['sortType']); if ($search) { $quizesQuery->where('topic', 'like', '%' . $search . '%'); } $quizes = $quizesQuery->paginate(self::$perPage); if ($search) { $quizes->appends(['search' => $search]); } //dd(DB::getQueryLog()); //dd($quizes->toArray()); self::addShareRates($quizes); return View::make('admin/quizes/view')->with(array('quizes' => $quizes, 'search' => $search)); }