Orderable column

Is it possible to pass a second parameter to orderable to order grouped by the second parameter? each group that has its order from 1 to X
4 Replies
Povilas K
Povilas K7mo ago
1. You mean sortable() and not orderable()? 2. This snippet may help if I understood correctly:
TextColumn::make('full_name')
->sortable(query: function (Builder $query, string $direction): Builder {
return $query
->orderBy('last_name', $direction)
->orderBy('first_name', $direction);
})
TextColumn::make('full_name')
->sortable(query: function (Builder $query, string $direction): Builder {
return $query
->orderBy('last_name', $direction)
->orderBy('first_name', $direction);
})
From docs: https://filamentphp.com/docs/3.x/tables/columns/getting-started#sorting
H.Bilbao
H.BilbaoOP7mo ago
I mean sortable. I have a table with the following columns: id, order, event_id, participant_id. And I want something like this: 1 1 1 1 2 2 1 2 3 3 1 3 4 1 2 1 5 2 2 2 6 3 2 3
Povilas K
Povilas K7mo ago
So yeah, write your custom function inside sortable()
H.Bilbao
H.BilbaoOP7mo ago
Sorry, sortable() no, I need reorderable() to order by groups I solved it by adding a filter, I always have one active so I can order each event independently
Want results from more Discord servers?
Add your server