How can I sort a table using a relationship?
In a column I have this relationship:
How can I apply a default sort?
I try it, but this is not work!
How can I apply a default sort?
I try it, but this is not work!
return $table
->columns([
Tables\Columns\TextColumn::make('enterprise.name')
->label('Empreendimento')
->sortable()
->searchable(),
... ->defaultSort(function ($query, $direction) {
$query->orderBy('enterprise.name');
})->defaultSort('enterprise.name')