SHARE
TWEET

Untitled

a guest Aug 14th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. User::select('users.*', DB::raw("SELECT MAX(id) FROM posts WHERE posts.firebase_id = users.firebase_id as recent_post_date"))
  2.      ->whereHas('posts', function ($q) {
  3.             $q->withCount('comments');
  4.      })
  5.      ->with(['posts' => function ($q) {
  6.             $q->withCount('comments')
  7.                ->orderBy('created_at', 'ASC');
  8.      }])
  9.      ->orderBy('recent_post_date', 'DESC')
  10.      ->get();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top