You may use Laravel's Query Builder as data source for your dataTables.
You can look at Yajra\Datatables\Enginges\QueryBuilderEngine
class which handles the conversion of your Query Builder into a readbale DataTable API response.
use DB;
use Datatables;
Route::get('user-data', function() {
$query = DB::table('users');
return Datatables::of($query)->make(true);
});
use DB;
use Datatables;
Route::get('user-data', function() {
$query = DB::table('users');
return Datatables::queryBuilder($query)->make(true);
});
use DB;
use Yajra\Datatables\Datatables;
Route::get('user-data', function(Datatables $datatables) {
$query = DB::table('users');
return $datatables->queryBuilder($query)->make(true);
});
use DB;
Route::get('user-data', function() {
$query = DB::table('users');
return app('datatables')->queryBuilder($query)->make(true);
});