F
Filament6mo ago
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.
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']),
1 Reply
DrByte
DrByte6mo ago
Can you extract and post the complete generated query?