Donations Appreciated

The simplest acts of kindness are by far more powerful then a thousand heads bowing in prayer. - Mahatma Gandhi

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

EloquentController.php - Overriding Global Search

Custom Filter

Id Name Email Created At Updated At


    public function getCustomFilter()
        return view('datatables.eloquent.custom-filter');

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

        return Datatables::of($users)
        ->filter(function ($query) use ($request) {
            if ($request->has('name')) {
                $query->where('name', 'like', "%{$request->get('name')}%");

            if ($request->has('email')) {
                $query->where('email', 'like', "%{$request->get('email')}%");


    var oTable = $('#users-table').DataTable({
        dom: "<'row'<'col-xs-12'<'col-xs-6'l><'col-xs-6'p>>r>"+
        processing: true,
        serverSide: true,
        ajax: {
            url: '',
            data: function (d) {
       = $('input[name=name]').val();
       = $('input[name=email]').val();
        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'}

    $('#search-form').on('submit', function(e) {