MySQL has a feature for getting the total number of records a query would return without a limit, SQL_CALC_FOUND_ROWS. Does Laravel support this?
Currently I have to do it in two queries:
public function dataTable() { $bookings = DB::table('bookings') ->limit(Input::query('iDisplayLength')) ->offset(Input::query('iDisplayStart')) ->get(); $count = $bookings = DB::table('bookings') ->count(); return Response::json([ 'iTotalRecords' => $count, ]); } Not only will this be less efficient, but there's going to be a lot of redundant code once I add in all the ->where() criteria.