Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. $users = User::with('role.role')->with('comments');
  2.  
  3. if (!empty($filters)) {
  4. $users->sorting($sorting);
  5. }
  6.  
  7. return $query->orderBy($sorting['field'], $sorting['direction']);
  8.  
  9. return $query->with(['role.role' => function ($q) use ($sorting) {
  10. $q->orderBy('name', $sorting['direction']);
  11. }]);
  12.  
  13. $query->whereHas('comments', function ($q) use ($operation, $votes) {
  14. $q->havingRaw("sum(up_votes + down_votes) $operation $votes");
  15. }, '>', 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement