jeudi 25 avril 2019

How to access table, related to pivot table in whereHas?

I have two models One and Two, related via pivot table 'one_two', which has own model OneTwo with hasOne Three. Now I want to get all One instances filtered by value in Three. This is what I tried and didn't success:

$ones = One::with('twos')->whereHas('twos', function($q) {$q->where('threes.value', 'yes');})->get();

How to do such thing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire