Searchable translatable column

Hi guys, I'm using a translation package (astrotomic) and I'm trying to make a column searchable, but it says it can't find the column, this is because that field is in the translations table and not in the resource model table . How can I modify the searchable function to do a join or something? Tables\Columns\TextColumn::make('title')->searchable()
No description
4 Replies
MoisesSegura
MoisesSeguraOP9mo ago
thx, i'm trying this solution but it seems still doesn't work: Tables\Columns\TextColumn::make('title')->searchable(query: function (Builder $query, string $search): Builder { return $query->join('laboral_document_translation', 'laboral_document.id', '=', 'laboral_document_translation.laboral_document_id') ->where('laboral_document_translation.title', 'like', "%{$search}%"); })
No description
MoisesSegura
MoisesSeguraOP9mo ago
I ended up making a filter to solve the issue: SelectFilter::make('id')->label('Titulo') ->options(LaboralDocument::all()->pluck('title', 'id')) ->searchable() ->preload()
Oleksandr Moik
Oleksandr Moik8mo ago
Instead simple title use translation.title Tables\Columns\TextColumn::make('translation.title')->searchable()
Want results from more Discord servers?
Add your server