Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'orderBy' option #89

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

YasamDevelopment
Copy link

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!

This was referenced May 4, 2021
@YasamDevelopment
Copy link
Author

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.

@briggsm
Copy link

briggsm commented May 12, 2021

#24 (comment) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants