F
Filament5mo 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
toeknee5mo ago
->defaultSort('user', 'desc') ?
ericmp
ericmp5mo ago
omg thanks 🙏
Mikail
Mikail2mo ago
worked for me too. Thanks