I have model many-to-many(including pivot table). I need to pull out only products that belongs to certian category. I'm trying this but it gives me all the products
$products= User::whereHas('category', function ($query) {
$query->where('id','1');
})->get();
1 in where is just for testing because when i put $id that was defined outside query it doesn't recognize it.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire