Laravel - is there a way to combine whereHas and with
问题 I'm currently facing a small problem. I want to return a model only if a relation with certain conditions exists. That's working fine with the whereHas()-method. $m = Model ::whereHas( 'programs', function($q) { $q->active(); } ); However, calling the relation as a property like this will give me all (not filtered results). $m->programs; So basically what I'm doing now is this: $m = Model ::whereHas( 'programs', function($q) { $q->active(); } ) ->with(array('programs' => function($q) { $q-