User orderby its activities #1252
Unanswered
mahboobsabiry
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I hope you all OK.
I want orderBy users by counting all its activities. Like:
User::orderBy(count($this->activities()), 'desc')->take(10);
My User Model:
public function activities () {return Activity::all()->where('causer_id', $this->id)->count();}
and my controller:User::all()->orderBy(count($this->activities()), 'desc)->take(10);
But it doesn't work.
Any help please
Beta Was this translation helpful? Give feedback.
All reactions