Hello !
How I can achieve an orderBy query like:
Resource::orderBy('field from relationship of resource')->paginate(X);
I tested something like orderBy('nameofrelationship.field to order') but It does not work.
I also tried:
Resource::with('nameofrelationship')->orderBy('nameofrelationship.field to order')->paginate(X);
I don't want to use the sort method of Collection ! I need to order my items in the mongodb query because I use a pagination !
Thanks a lot !
Hi!
I'm on the same problem, anyone have a solution? I thought in use aggregate to do the trick, but that looks like a bazooka to killing an ant.
Hi!
I'm on the same problem, anyone have a solution?
Hello,
Use mongodb raw query, this is not a simple SQL.
Thanks.
Most helpful comment
Hi!
I'm on the same problem, anyone have a solution? I thought in use aggregate to do the trick, but that looks like a bazooka to killing an ant.