It is working but I should do with Relaion
x
SELECT * FROM product JOIN ware_houses ON product.id=ware_houses.product_id WHERE ware_houses.variant_id=1;
Like this…
Product::whereHas('ware_houses')->where('ware_houses.product_id',1)->get();
But it is not working because whereHas
returns a collection, What I can do ??? Please give advice.
Advertisement
Answer
This is working thank you !!!
$products=Product::whereHas('wareHouse',function(Builder $query) use ($id){
$query->where('ware_houses.variant_id',$id);
})->get();