Skip to main content
added 180 characters in body
Source Link
Sumit kumar
  • 412
  • 2
  • 12

You're doing get() so your controller fetching all the data first and then sending the data into yajra/datatable on frontend.

you can do it like this(enable paging:true in dt on frontend):

$model = ModelName::query();
$dt = new DataTables();
return $dt->eloquent($model)->toJson();

paging:true fetches only data to be displayed on datatable pagination. Do it like this for using db facades:

$users = DB::table('tableName');
$dt = new DataTables();
return $dt->query($users)->toJson(); //datatables will do the rest

You're doing get so your controller fetching all the data first and then sending the data into yajra/datatable on frontend.

you can do it like this(enable paging:true in dt on frontend):

$model = ModelName::query();
$dt = new DataTables();
return $dt->eloquent($model)->toJson();

paging:true fetches only data to be displayed on datatable pagination.

You're doing get() so your controller fetching all the data first and then sending the data into yajra/datatable on frontend.

you can do it like this(enable paging:true in dt on frontend):

$model = ModelName::query();
$dt = new DataTables();
return $dt->eloquent($model)->toJson();

paging:true fetches only data to be displayed on datatable pagination. Do it like this for using db facades:

$users = DB::table('tableName');
$dt = new DataTables();
return $dt->query($users)->toJson(); //datatables will do the rest
Source Link
Sumit kumar
  • 412
  • 2
  • 12

You're doing get so your controller fetching all the data first and then sending the data into yajra/datatable on frontend.

you can do it like this(enable paging:true in dt on frontend):

$model = ModelName::query();
$dt = new DataTables();
return $dt->eloquent($model)->toJson();

paging:true fetches only data to be displayed on datatable pagination.