Skip to content
Icon

WARNING You're browsing the documentation for an old version of LARAVEL-DATATABLES. Consider upgrading your project to laravel-datatables 10.0.

Only Response

Get only selected columns in response.

use DataTables;
 
Route::get('user-data', function() {
$model = App\User::query();
 
return DataTables::eloquent($model)
->only(['id','name'])
->toJson();
});

Example Response

{
"draw": 2,
"recordsTotal": 10,
"recordsFiltered": 2,
"data": [{
"id": 476,
"name": "Esmeralda Kulas"
}, {
"id": 6,
"name": "Zachery Muller"
}]
}