src/Http/Datatables/Administrators.php
public function ajax()
    {
        $acl            = app('antares.acl')->make('antares/acl');
        $canUpdateUser  = $acl->can('user-update');
        $canDeleteUser  = $acl->can('user-delete');
        $canLoginAsUser = $acl->can('login-as-user');

        return $this->prepare()
                        ->filter(function($query) {
                            $request = app('request');
                            $keyword = array_get($request->get('search'), 'value');
                            if (is_null($keyword) or ! strlen($keyword)) {
                                return;
                            }
                            switch ($keyword) {
                                case 'active':
                                    $query->where('tbl_users.status', 1);
                                    break;
                                case 'archived':
                                    $query->where('tbl_users.status', 0);
                                    break;
                                default:
                                    $query
                                    ->leftJoin('tbl_user_role', 'tbl_users.id', '=', 'tbl_user_role.user_id')
                                    ->leftJoin('tbl_roles', 'tbl_user_role.role_id', '=', 'tbl_roles.id')
                                    ->whereRaw("(tbl_users.firstname like '%$keyword%'  or tbl_users.lastname like '%$keyword%' or tbl_users.email like '%$keyword%' or tbl_roles.full_name like '%$keyword%')");
                                    break;
                            }
                        })
                        ->filterColumn('status', function ($query, $keyword) {
                            if ($keyword == 'all') {
                                $query->whereIn('tbl_users.status', [0, 1]);
                            } else {
                                $query->where('tbl_users.status', $keyword);
                            }
                        })
                        ->editColumn('status', function ($model) {
                            return ((int) $model->status) ? '<span class="label-basic label-basic--success">ACTIVE</span>' : '<span class="label-basic label-basic--danger">Disabled</span>';
                        })
                        ->editColumn('email', $this->getUserEmail($eloquent = null))
                        ->editColumn('role', $this->userRoles($eloquent = null))
                        ->editColumn('firstname', function($eloquent = null) {
                            return strlen($eloquent->firstname) <= 0 ? '---' : $eloquent->firstname;
                        })
                        ->editColumn('lastname', function($eloquent = null) {
                            return strlen($eloquent->lastname) <= 0 ? '---' : $eloquent->lastname;
                        })
                        ->editColumn('created_at', function ($model) {
                            return format_x_days($model->created_at);
                        })
                        ->addColumn('action', $this->getActionsColumn($canUpdateUser, $canDeleteUser, $canLoginAsUser))
                        ->make(true);
    }
public function ajax()
    {
        $acl            = app('antares.acl')->make('antares/acl');
        $canUpdateUser  = $acl->can('user-update');
        $canDeleteUser  = $acl->can('user-delete');
        $canLoginAsUser = $acl->can('login-as-user');

        return $this->prepare()
                        ->filter(function($query) {
                            $request = app('request');
                            $keyword = array_get($request->get('search'), 'value');
                            if (is_null($keyword) or ! strlen($keyword)) {
                                return;
                            }
                            switch ($keyword) {
                                case 'active':
                                    $query->where('tbl_users.status', 1);
                                    break;
                                case 'archived':
                                    $query->where('tbl_users.status', 0);
                                    break;
                                default:
                                    $query
                                    ->leftJoin('tbl_user_role', 'tbl_users.id', '=', 'tbl_user_role.user_id')
                                    ->leftJoin('tbl_roles', 'tbl_user_role.role_id', '=', 'tbl_roles.id')
                                    ->whereRaw("(tbl_users.firstname like '%$keyword%'  or tbl_users.lastname like '%$keyword%' or tbl_users.email like '%$keyword%' or tbl_roles.full_name like '%$keyword%')");
                                    break;
                            }
                        })
                        ->filterColumn('status', function ($query, $keyword) {
                            if ($keyword == 'all') {
                                $query->whereIn('tbl_users.status', [0, 1]);
                            } else {
                                $query->where('tbl_users.status', $keyword);
                            }
                        })
                        ->editColumn('status', function ($model) {
                            return ((int) $model->status) ? '<span class="label-basic label-basic--success">ACTIVE</span>' : '<span class="label-basic label-basic--danger">Disabled</span>';
                        })
                        ->editColumn('email', $this->getUserEmail($eloquent = null))
                        ->editColumn('role', $this->userRoles($eloquent = null))
                        ->editColumn('firstname', function($eloquent = null) {
                            return strlen($eloquent->firstname) <= 0 ? '---' : $eloquent->firstname;
                        })
                        ->editColumn('lastname', function($eloquent = null) {
                            return strlen($eloquent->lastname) <= 0 ? '---' : $eloquent->lastname;
                        })
                        ->editColumn('created_at', function ($model) {
                            return format_x_days($model->created_at);
                        })
                        ->addColumn('action', $this->getActionsColumn($canUpdateUser, $canDeleteUser, $canLoginAsUser))
                        ->make(true);
    }
{@inheritdoc}