Sortable and Searchable in pivot column not working
I have a many-to-many relationship between Company and Person.
The pivot table and model (CompanyPerson) has an office column that refers to another model.
The data displays correctly in the table when accessing "pivot.office.name", but the ->searchable() and ->sortable() methods don’t work.
What is the best way to fix this?
This is the error I get when trying to search for an office name:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pivot' in 'WHERE'
select
count(*) as aggregate
from
companies
inner join company_person
on companies
.id
= company_person
.company_id
where
company_person
.person_id
= 1
and (
json_unquote(json_extract(pivot
, '$."office"."name"')) like % a %
)
and companies
.deleted_at
is null
And this is the table:
Everything works, except making the pivot column searchable and sortable.0 Replies