© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Marko Andonov

Searchable columns not working with applySearchToTableQuery

Hi guys I am facing an issue when using
->searchable()
->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()
->searchable()
or with the
applySearchToTableQuery
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",
"filament/filament": "3.2.2",

- ListRecords applySearchToTableQuery
    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;
    }
    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),
                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),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Searchable Not Working
FilamentFFilament / ❓┊help
3y ago
Debounce on searchable() columns
FilamentFFilament / ❓┊help
3y ago
Searchable not working in column
FilamentFFilament / ❓┊help
3y ago
Toggleable columns not working with Split
FilamentFFilament / ❓┊help
3y ago