F
Filament10mo 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));
})
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?
4 Replies
dyo
dyoOP10mo ago
anyone can help me?
morty
morty10mo ago
What doesn't work? What is the query that is generated?
dyo
dyoOP10mo ago
thanks for your response.. let me explain more the first image or case, the user try to search the phone number using from whatsapp number contact whatsapp the second image or case, user try to search the phone number in the form of exactly like in the database. I want the first case to also return the data..
No description
No description
dyo
dyoOP10mo ago
i've tried debugging with this, still no result
Tables\Columns\TextColumn::make('hp')
->searchable(query: function (Builder $query, string $search): Builder {
// $search = ConvertPhone::nomor($search);
$search = 628880778033;

// return $query->where('hp', 'like', "%$search%");
return $query->where('hp', $search);
})
Tables\Columns\TextColumn::make('hp')
->searchable(query: function (Builder $query, string $search): Builder {
// $search = ConvertPhone::nomor($search);
$search = 628880778033;

// return $query->where('hp', 'like', "%$search%");
return $query->where('hp', $search);
})
Want results from more Discord servers?
Add your server