imsus
imsus
FFilament
Created by imsus on 8/27/2023 in #❓┊help
Has anyone successfully integrating admin panel with Laravel Scout yet?
Found it, so this is the correct way On table() function
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')->label('ID')->searchable(query: fn (Builder $query): Builder => $query),
// 1. At least there is 1 searchable columns to show search field
// 2. The callback should return NON-MODIFIED $query. By default filament will add ->where('id', 'like', '%$value%') on every searchable column.
])
->modifyQueryUsing(function (Builder $query) use ($table): Builder {
$search = str($table->getSearchIndicator())->after(': ')->__toString();
// 3. This is the only way that I can get the search query inputted.

return $query->whereIn('id', YourSearchableModel::search($search)->keys());
})
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')->label('ID')->searchable(query: fn (Builder $query): Builder => $query),
// 1. At least there is 1 searchable columns to show search field
// 2. The callback should return NON-MODIFIED $query. By default filament will add ->where('id', 'like', '%$value%') on every searchable column.
])
->modifyQueryUsing(function (Builder $query) use ($table): Builder {
$search = str($table->getSearchIndicator())->after(': ')->__toString();
// 3. This is the only way that I can get the search query inputted.

return $query->whereIn('id', YourSearchableModel::search($search)->keys());
})
}
4 replies