Laravel 4: fetching only models that have related models
问题 I want to only retrieve a model(s) when they have a specific related model present e.g. $posts = Post::has('comment')->get(); that works fine although the opposite does not: $comments = Comment::has('post')->get(); I get the following error: Has method invalid on "belongsTo" relations. Basically the reason i want to do this is that in exceptional circumstances there are cases that when i call a related model in a view, that model may not have a related model present (even when it should)