2

I'm trying to create a multi-tenant application where there are Buyer and Seller companies, but having a hard time findig out how to store and associate companies with each other. This is a shared multi-tenant architecture having a single database and shared tables with "company_id" FK column in every table. I use PHP and mySQL, and would like to create this in Laravel 4 framework with Eloquent ORM. I'm new to Laravel.

  • Both Buyers and Sellers can can have many users. Both can invite each other to the application. After this, they can place order, and invoice the other party.
  • Both parties can add the other party on their own partner list before invitation. This way, for example Sellers can add orders and create invoice for Buyers that don't want to register and place order for themselves.
  • Also there will be occasional buyers that are not invited, and placing orders through Sellers' shopping cart (seller.myapp.com/products) that is connected to the application and lists the products of only that particular seller. So these buyers will register through this seller.

I'm confused how the invitation, registration, and adding companies manually can work together when it comes to storing and associating parties. For example when a Seller adds a Buyer to their own list and also invites buyer, buyer needs to login under that particular seller's account in order to see orders and invoices related to that seller. But Buyer can be added and invited by many Sellers. It creates a problem: How can buyer see all his orders from those different sellers together without login in to each seller's account?

Or if choose the approach where Buyer registers a new, separate account (not under inviter's account) after invitation, how can this new account be associated with his company data on Seller's side?

What is the best approach? I'm interested in the database-structure and how the relations should look like. This is not about party model.

Thank you

4

0 回答 0