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

Adding sorting by scope #549

Closed
jersonmr opened this issue Sep 5, 2020 · 2 comments
Closed

Adding sorting by scope #549

jersonmr opened this issue Sep 5, 2020 · 2 comments

Comments

@jersonmr
Copy link

jersonmr commented Sep 5, 2020

Hi there! I'd like to know if there is a way to get resources sorted by a scope? I know the package allow realize sorting by columns of the model but if I need realize sort by a related resource? Or by countable related resource?

Something like this:

public function scopeSortByLikes($query)
    {
        return $query->withCount('likes')
                ->orderBy('likes_count', $direction);
        });
    }

Thanks!

@lindyhopchris
Copy link
Member

Hi!

Good suggestion... I've added something to the adapter so you can implement the sortByLikes method on the adapter. An example is now in the sorting chapter of the docs - at the end of the chapter.

This will be in 2.2.0 and 3.0.0 - I'm just sorting out tagging versions at the moment.

@jersonmr
Copy link
Author

jersonmr commented Sep 9, 2020 via email

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

No branches or pull requests

2 participants