I am trying to develop multiple-shop eCommerce platform. So the following tables created:
shops: id, name, ...
products: id, shop_id, ...
orders: id, ...
order_details: id, order_id, product_id, ...
And this is the summery of my models' relationships:
- Shop->products: Shop hasMany Product
- Product->shop: Product belongsTo Shop
- Order->details: Order hasMany OrderDetail
- OrderDetail->order: OrderDetail belongsTo Order
- OrderDetail->product: OrderDetail belongsTo Product
- Product->orders: Product hasMany OrderDetail
Now, 1: Is it possible to define Shop->orders relationship?(It seams has-many-through not works in this case due to multiple intermediate tables)
2: If it is possible, could the shop->orders->details contains only the records related to shop products?
It should be note that each Order may contain products from multiple shops but the shop->orders->details relation should contains only the shop products.