Searchable columns not working with applySearchToTableQuery

Hi guys I am facing an issue when using ->searchable() on columns in the resource table but when using the applySearchToTableQuery function into ListRecords class then the searchable columns are not included and the query doesn't work right.
So I can either search with ->searchable() or with the applySearchToTableQuery function.

I am having Order with many Tickets (hasMany) and I want into the OrderResource to search by order id, name, email, etc... but also to modify the search query to search the tickets by their first_name, last_name and email.

  • Filament version: "filament/filament": "3.2.2",
  • ListRecords applySearchToTableQuery```php protected function applySearchToTableQuery(Builder $query): Builder { $this->applyColumnSearchesToTableQuery($query); if (filled($search = $this->getTableSearch())) { $like = '%'.$search.'%'; $query->whereIn('id', Ticket::select('order_id') ->whereAny([DB::raw("CONCAT(`first_name`, ' ', `last_name`)"), 'email'], 'like', $like) ); } return $query; }```
So the only way to make this work is to include them into my OrderResource with toggable option and to comment the applySearchToTableQuery.

  • OrderResource toggable columns
                  Tables\Columns\TextColumn::make('tickets.first_name')
                      ->searchable()
                      ->label('Имиња на пријави')
                      ->toggleable(isToggledHiddenByDefault: true),
                  Tables\Columns\TextColumn::make('tickets.last_name')
                      ->searchable()
                      ->label('Презимиња на пријави')
                      ->toggleable(isToggledHiddenByDefault: true),
                  Tables\Columns\TextColumn::make('tickets.email')
                      ->searchable()
                      ->label('Е-пошти на пријави')
                      ->toggleable(isToggledHiddenByDefault: true),
Was this page helpful?