/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $start = $request->input('start', 0); $length = $request->input('length', 5); $draw = $request->input('draw', 1); $role = Role::skip($start)->take($length)->orderBy('id', 'desc'); echo json_encode(array("draw" => intval($draw), "recordsTotal" => intval(Role::count()), "recordsFiltered" => intval(Role::count()), "data" => $role->get()->toArray())); }