Added 'orderBy' option
Hi Brian,
I'm pretty new when it comes to creating pull requests, and I don't thoroughly understand your (and Nova's) codebase, but I hope this Pull Request will at least give you a good idea of a way to implement an "orderBy" option with which the user can specify the columns by which to order the listing by.
Just as an example as to how this would look in a Resource, which uses your AttachMany field:
AttachMany::make('People')
->showRefresh()
->orderBy(['last_name', 'first_name']),
Please let me know if there's anything else I can do from my end.
Thank you for your very useful & helpful tool!
Hi @dillingham,
I added another commit to this pull request - to allow for user to specify "ASC" or "DESC" sort direction. So now the user could specify the AttachMany field like so:
AttachMany::make('People')
->showRefresh()
->orderBy(['last_name => 'ASC', 'first_name', 'age' => 'desc']),
- 'asc' or 'desc' is case-insensitive
- If any elements in the 'orderBy' array don't specify 'asc' or 'desc', ascending is assumed.
Please let me know if you have any other questions, or if there's anything else I could do.
Thanks again.
https://github.com/dillingham/nova-attach-many/issues/24#issuecomment-839254550 posted by @davejamesmiller shows how "sorting" can quite easily be done without the need for this Pull Request or changing any code in this repository. This Pull Request can be closed.