FilamentF
Filament2y ago
dyo

problem with customized searchable text column

https://filamentphp.com/docs/2.x/tables/columns/getting-started#searching

Does anyone know the correct way to custom the results from searchable in textcolumn?

So in this case, there is a cellphone column whose example data format is 6285265213796

but admin users often search for cellphone number data in the format of the results from copying and pasting numbers on WA, for example +62 852 6521 3796

I've tried

Tables\Columns\TextColumn::make('phone')
     ->searchable(query: function (Builder $query, string $search): Builder {
         return $query->where('phone', ConvertPhone::number($search));
     })


The classes and methods above are also used in other cases, and convert the cellphone number format correctly, according to the data in the database.

but when used in textcolumn, the script above doesn't work as expected.
What should I do?
Was this page helpful?