lundi 30 octobre 2017

Laravel query from collection

I'm trying to filter Members who have Groups that are of a different type through the relations. I want it to filter it to only those Members, but instead it seems to still return all members of that type. This is the code I've been using:

$members = Member::where('type', 1)->with(['groups' => function ($query) {
      $query->where('type', 0);}])->get();

What I want is something like this (although this generates an error):

$members = Member::where('type', 1)->where(['groups' => function ($query) {
      $query->where('type', 0);}])->get();

Is there a different approach I could use do this?



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

Aucun commentaire:

Enregistrer un commentaire