Check Model has() Relation
To check if a model has a relation you can make use of this method like below. Imagine you want to know whether a post has a comment, if it does then eager load it together.
<?php $postHaveComments = Post::has('comments') ->with('comments') ->get();
Check Model doesntHave Relation
To check if a model doesn't have a relation, then you can write it like below. The query will return only the model that doesn't have a comments.
<?php $postHasNoComments = Post::doesntHave('comments') ->get();