im trying to join two tables post
and comment
using ORM relations,
$posts = Post::with('comments')->get();
how can i use condition on comments when using with
to join tables?
i can use whereHas like
$posts = Post::whereHas('comments', function ($query) {
if(isset($_GET['title']))
$query->where('title', $_GET['title']);
})->get();
but when i use whereHas
i wouldn't get the post without any comment in the result
basically i want to use left join with condition on the right table