The code:
$posts = Jumpsite::find($jid)
->posts()
->with(\'comments\')
->with(\'likes\')
->with(\
You can use that following code for counting relation model result.
$posts = App\Post::withCount('comments')->get(); foreach ($posts as $post) { echo $post->comments_count; }
And also set condition with count like this
$posts = Post::withCount(['votes', 'comments' => function ($query) { $query->where('content', 'like', 'foo%'); }])->get();