F
Filament11mo ago
πTeR

How can I sort a table using a relationship?

In a column I have this relationship:
return $table
->columns([
Tables\Columns\TextColumn::make('enterprise.name')
->label('Empreendimento')
->sortable()
->searchable(),
...
return $table
->columns([
Tables\Columns\TextColumn::make('enterprise.name')
->label('Empreendimento')
->sortable()
->searchable(),
...
How can I apply a default sort? I try it, but this is not work!
->defaultSort(function ($query, $direction) {
$query->orderBy('enterprise.name');
})
->defaultSort(function ($query, $direction) {
$query->orderBy('enterprise.name');
})
Solution:
->defaultSort('enterprise.name')
->defaultSort('enterprise.name')
...
Jump to solution
2 Replies
Solution
DrByte
DrByte11mo ago
->defaultSort('enterprise.name')
->defaultSort('enterprise.name')
πTeR
πTeROP11mo ago
Thank you @DrByte o/
Want results from more Discord servers?
Add your server