Level 52
Look there.
7 likes
Is there a way to use whereHas() and with() but retain the where()? I know I can do this but I was wondering if there is a better way.
$posts = Post::whereHas('comments', function ($query) {
$query->where('content', 'like', 'foo%');
})->with(['comments' => function ($query) {
$query->where('content', 'like', 'foo%');
}])->get();
Please or to participate in this conversation.