Donations Appreciated

Doing nothing for others is the undoing of ourselves. - Horace Mann

Click here to lend your support to: Laravel Datatables and make a donation at pledgie.com !

EloquentController.php - Basic Demo with Object Data Source

Since v6.0, you can now optionally set column.name value to null. The package will automatically use column.data value as column name when filtering and sorting records.

NOTE: This is only applicable if your column name is the same with the data to display. If not, you need to specify column.name on your script.
Id Name Email Created At Updated At

EloquentController.php

    public function getBasicObject()
    {
        return view('datatables.eloquent.basic-object');
    }

    public function getBasicObjectData()
    {
        return Datatables::of(User::query())->make(true);
    }

Javascript

    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: 'https://datatables.yajrabox.com/eloquent/basic-object-data',
        columns: [
            {data: 'id'},
            {data: 'name'},
            {data: 'email'},
            {data: 'created_at'},
            {data: 'updated_at'}
        ]
    });