malinga91's avatar

Order have products from different stores

I'm working on a project which include shopping cart. Basic requirement is,

  • Each product belongs to a store
  • Order can have multiple products from different stores
  • Each store owner will have separate login.
  • A store owner should be able view basic order details and ordered product details that belongs to the store.

Current database structure is,

stores
	- id
	- name

products
	- id
	- store_id
	- name
	- amount

orders
	- id
	- customer_name
	- address
	- cart_total

order_products
	- id
	- order_id
	- product_id
	- price
//
Hotel Model
public function order_products()
    {
        return $this->hasManyThrough('App\OrderProduct', 'App\Product');
    }

How to write App\Hotel model to get order details? Should I add column('hotel_id') in order_products table?

0 likes
3 replies
deepu07's avatar

@malinga91 you can also create a one more pivot table hotel_order table and get the value from there

malinga91's avatar

@deepu07 Great... one thing. But how can I get the order items that belongs to a particular store?

Please or to participate in this conversation.