mercredi 25 novembre 2015

Laravel 5 - ORM has() Relationship (Inverse - notHas)

In the Laravel 5 I can find all posts that have at least one comment using has method:

// Retrieve all posts that have at least one comment...
$posts = App\Post::has('comments')->get();

As theres no method like notHas, how can I find all posts that have no comments? (remembering that it's a hasMany relationship)


Reference:

Querying Relationship Existence

http://ift.tt/1IbMHFY



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1N8I4s8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire