F
Filament12mo ago
danzzz

Search also in hidden or not used columns

How can I include a column which I dont use in a table also in the table serach? I tried to hidde the column, but then it will be ignored when searching.
Solution:
If you have it as included but toggle it's visibility to hidden by default it will be included in the search. Or if you adjust the table search query with say: ```php protected function applySearchToTableQuery(Builder $query): Builder...
Jump to solution
4 Replies
Solution
toeknee
toeknee12mo ago
If you have it as included but toggle it's visibility to hidden by default it will be included in the search. Or if you adjust the table search query with say:
protected function applySearchToTableQuery(Builder $query): Builder
{
if (filled($searchQuery = $this->getTableSearch())) {

$query->where('my_column', 'like', '%'.$searchQuery.'%');
}

return $query;
}
protected function applySearchToTableQuery(Builder $query): Builder
{
if (filled($searchQuery = $this->getTableSearch())) {

$query->where('my_column', 'like', '%'.$searchQuery.'%');
}

return $query;
}
to he List page it will be included.
danzzz
danzzzOP12mo ago
do you meand ->visible() or isVisible() methods ?
toeknee
toeknee12mo ago
no, ->toggleable( isHiddenByDefault: true)
danzzz
danzzzOP12mo ago
oh yes, thx. but the "applySearchToTableQuery" solution fits nicely, thx
Want results from more Discord servers?
Add your server