© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
daar

Searchable and sortable on polymorph

Hi, how to implement a search based on a polymorphic relation with a relationship one down even?

With the following code I get the error for sorting:
Call to a member function getRelated() on null
Call to a member function getRelated() on null
.

On searching I get:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.'first_name' like ? or 'consultable'.'patientStatus'.'patient'.'last_name' like' at line 1
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.'first_name' like ? or 'consultable'.'patientStatus'.'patient'.'last_name' like' at line 1


Seems like a bug in Filament? The code used is shown below:
Tables\Columns\TextColumn::make('consultable.patientStatus.patient.full_name')
    ->searchable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name'])
    ->sortable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name']),
Tables\Columns\TextColumn::make('consultable.patientStatus.patient.full_name')
    ->searchable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name'])
    ->sortable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name']),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Is sortable() and/or searchable() possible on a HasOneThrough relation?
FilamentFFilament / ❓┊help
16mo ago
Sortable and Searchable in pivot column not working
FilamentFFilament / ❓┊help
5mo ago
->sortable(), searchable(), and pagination not working with Livewire
FilamentFFilament / ❓┊help
2y ago
How to searchable and sortable my custom column?
FilamentFFilament / ❓┊help
3y ago