laravel-datatables-docs icon indicating copy to clipboard operation
laravel-datatables-docs copied to clipboard

filterColumn wrong behavior?

Open diorgesl opened this issue 9 months ago • 1 comments

Look this code

public function plex_cliente_datatables() {
        $clientes = PlexCliente::query();
        return DataTables::eloquent($clientes->with('servicos_alias'))
            ->addColumn('servicos_alias', function(PlexCliente $c) {
                $servicos = null;
                foreach($c->servicos_alias as $servico) {
                    $servicos .= $servico->id . ($servico->alias ? '(' . $servico->alias . ')' : ''). ', ';
                }
                return substr($servicos, 0, -2);
            })
            ->filterColumn('cpf_cnpj', function($query, $keyword) {
                $sql = "REPLACE(REPLACE(REPLACE(cpf_cnpj, '.', ''), '-', ''), '/', '')  LIKE ?";
                $keyword = preg_replace('/\D/', '', $keyword);
                $query->whereRaw($sql, ["%{$keyword}%"]);
            })
            ->toJson();
    }

When I use the filterColumn, the search works only for this column.

Can you help how to fix this?

diorgesl avatar May 10 '24 20:05 diorgesl