Object Response
To convert the response of Datatables to an object, just pass true
on make
api.
use Datatables; Route::get('user-data', function() { $model = App\User::query(); return Datatables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true);});
Example Response
{ "draw": 2, "recordsTotal": 10, "recordsFiltered": 3, "data": [{ "id": 476, "name": "Esmeralda Kulas", "created_at": "2016-07-31 23:26:14", "updated_at": "2016-07-31 23:26:14", "deleted_at": null, "superior_id": 0 }, { "id": 6, "name": "Zachery Muller", "created_at": "2016-07-31 23:25:43", "updated_at": "2016-07-31 23:25:43", "deleted_at": null, "superior_id": 1 }]}