You may use Laravel's Eloquent Model as data source for your dataTables.
You can look at Yajra\DataTables\EloquentDataTable
class which handles the conversion of your Eloquent Model into a readable DataTable API response.
use DataTables;
Route::get('user-data', function() {
$model = App\User::query();
return DataTables::of($model)->toJson();
});
use DataTables;
Route::get('user-data', function() {
$model = App\User::query();
return DataTables::eloquent($model)->toJson();
});
use Yajra\DataTables\DataTables;
Route::get('user-data', function(DataTables $dataTables) {
$model = App\User::query();
return $dataTables->eloquent($model)->toJson();
});
Route::get('user-data', function() {
$model = App\User::query();
return app('datatables')->eloquent($model)->toJson();
});
use Yajra\DataTables\EloquentDataTable;
Route::get('user-data', function() {
$model = App\User::query();
return (new EloquentDataTable($model))->toJson();
});