lundi 2 mai 2016

How to use whereHas on multilevel relationship in Laravel

How to use whereHas on multilevel relationship like:

$parentCats = Category::with( 'children', 'children.products', 'children.products.productDetails' );

Now I want to do query like:

$parentCats = $parentCats->whereHas( 'children.products.productDetails', function ($q2) use ($size) { $q2->where('size', '=', $size); } )->find($id);

this query is giving all data. But I want data only where productDetails have given size.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire