Donations Appreciated

No one has ever become poor by giving. - Anne Frank, diary of Anne Frank

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

EloquentController.php - Basic Demo

IMPORTANT: When using make(), the package will rely filtering and sorting based on the index/arrangement of your select query.


NEVER USE SELECT(*) when using this approach or your DataTables filtering/sorting may not work properly.

Id Name Email Created At Updated At

EloquentController.php

    public function getBasic()
    {
        return view('datatables.eloquent.basic');
    }

    public function getBasicData()
    {
        $users = User::select(['id','name','email','created_at','updated_at']);

        return Datatables::of($users)->make();
    }

Javascript

    $(function() {
        $('#users-table').DataTable({
            processing: true,
            serverSide: true,
            ajax: 'https://datatables.yajrabox.com/eloquent/basic-data'
        });
    });