public function getFiltrarrazas(Request $request) { if (!$request->ajax()) { abort(403); } $datos = array(); $inputs = $request->all(); if (empty($inputs['search'])) { $razas = \App\Raza::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id', 'raza', 'id_tipo_raza')->where('id', '>', 0)->take($inputs['limit'])->skip($inputs['offset'])->orderBy('created_at', 'ASC')->get(); } else { $razas = \App\Raza::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id', 'raza', 'id_tipo_raza')->where('raza', 'LIKE', '%' . $inputs["search"] . '%')->take($inputs['limit'])->skip($inputs['offset'])->orderBy('created_at', 'ASC')->get(); } $cantidad = \DB::select(\DB::raw("SELECT FOUND_ROWS() AS total;")); $cantidad = $cantidad[0]->total; $n = 1; foreach ($razas as $raza) { $url = '<a href="' . route('raza.edit', $raza->id) . '" class="btn btn-xs btn-success"><i class="fa fa-btn fa-edit"></i>Editar</a>'; $datos[] = ['num' => $n++, 'raza' => $raza->raza, 'tipo' => \App\TipoRaza::where('id', $raza->id_tipo_raza)->first()->tipo_raza, 'act' => $url]; } return \Response::json(['total' => $cantidad, 'rows' => $datos]); }