Laravel Eloquent Check for Nested Relation
Imagine you have a "Post" model that has a "Comments" relation which then has a "Likes" relation, you can do the checking as follows.
<?php Post::has('comments.likes')->get(); // the post has "comments" and "likes"
Do note that the relationship has to be defined as "hasMany".
Post => hasMany Comments Comment => hasMany Likes
Leave a reply