F
Filamentβ€’11mo ago
ericmp

How to apply sortable by default on tables

in my users resource, by default i modify the query like so:
User::query()->latest()
User::query()->latest()
i do it to sort it by default, by more recents created first. but now i added the created_at field to the user resource table, so the user choose the sorting there. but as i am manually applying the sorting, now the user cant sort be date since always applies the latest() so the question is, how to correctly apply the initial sorting but then let the user change it?
3 Replies
toeknee
toekneeβ€’11mo ago
->defaultSort('user', 'desc') ?
ericmp
ericmpOPβ€’11mo ago
omg thanks πŸ™
Mikail
Mikailβ€’8mo ago
worked for me too. Thanks
Want results from more Discord servers?
Add your server