Donations Appreciated

You have not lived today until you have done something for someone who can never repay you. - John Bunyan

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

EloquentController.php - Blacklist Columns

Sorting and searching will not work on columns explicitly defined as blacklisted.

->blacklist(['password', 'name'])
Id Name Email Created At Updated At

EloquentController.php

    public function getBlacklist(Request $request)
    {
        if ($request->ajax()) {
            return Datatables::of(User::query())
                ->blacklist(['password', 'name'])
                ->make(true);
        }

        return view('datatables.eloquent.blacklist');
    }

Javascript

    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: '',
        columns: [
            {data: 'id', name: 'id'},
            {data: 'name', name: 'name'},
            {data: 'email', name: 'email'},
            {data: 'created_at', name: 'created_at'},
            {data: 'updated_at', name: 'updated_at'}
        ]
    });