I have the following tables
- Purchases
- Products
- Sales
and following relations
- Purchase has many products
- Sale Has many products
- Product has many sales
- Product belongs to purchase
I want to get the sold products of a purchase. so my query was like this
$purchase = Purchases::with(['product','product.sale' => function ($query){
return $query->where('status','complete');
}])->find($request->id);
My question is the status is getting checked in the sales table? If it's not then is there any way without using raw query I can check the following condition in sales table?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GwMnpg
via IFTTT
Aucun commentaire:
Enregistrer un commentaire