CodeIgniter Forums
Seeking advices in how to create several accounts for a single vendor. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Seeking advices in how to create several accounts for a single vendor. (/showthread.php?tid=70326)



Seeking advices in how to create several accounts for a single vendor. - castle - 03-25-2018

Hello,

I'm building an multi-vendor ecommerce website and I need some help with a request that I just got. By default, the website will create a single account per vendor. The request I got is to allow several accounts for a single vendor. For example:

Let's say the vendor ACME is a big retail shop and it wants to list their products on my website. Because of ACME's size, each department manager will be responsible for the products listing. That means the website will need to create an account for each department's manager. 

My question is how do I go from one account per vendor to multiple accounts per vendor? How would you design/change your DB scheme?

Regards,
Castle


RE: Seeking advices in how to create several accounts for a single vendor. - albertleao - 03-25-2018

Take a look at this.

https://web.archive.org/web/20110311185417/http://msdn.microsoft.com/en-us/library/aa479086.aspx


RE: Seeking advices in how to create several accounts for a single vendor. - castle - 03-25-2018

Sorry, I don't see how it could help me.


RE: Seeking advices in how to create several accounts for a single vendor. - Krycek - 03-26-2018

Use a table companies (vendor) and connect the account(s) to a company.
So 1 account can have 1 company, but 1 company can have multiple accounts.


RE: Seeking advices in how to create several accounts for a single vendor. - mladoux - 03-26-2018

(03-26-2018, 12:04 AM)Krycek Wrote: Use a table companies (vendor) and connect the account(s) to a company.
So 1 account can have 1 company, but 1 company can have multiple accounts.

Try making a column on the account table that refers to the vendor the account belongs to? Perhaps a foreign key 'vendor_id' that references 'id' on the 'vendors' table? I'm not going to write the SQL for you, but that should get you started.


RE: Seeking advices in how to create several accounts for a single vendor. - skunkbad - 03-26-2018

If I was doing it, Vendor would be a role in my authentication, and any person logged in as Vendor would be able to manage the creation/removal of Subvendors (or whatever I was told to name them). This would be super simple, and Community Auth already comes set up to manage role based authentication, and all I'd need to do is implement some basic logic on user creation.


RE: Seeking advices in how to create several accounts for a single vendor. - castle - 03-26-2018

Thank you guys. Do you mean something like this? (plz see the attachment).

@skunkbad i'll check your library.