orchestral / tenanti

[Package] Multi-tenant Database Schema Manager for Laravel
MIT License
587 stars 53 forks source link

example project or code #17

Closed ghost closed 9 years ago

ghost commented 9 years ago

hello,

i'm wondering if maybe someone could share any example project or code on how this exactly is implemented in practice. i've tried around multi database but there are certain things i do not understand correctly.

basically i'm having a centralized database for accounting (acounting_db), which stores all accounts and tenant instances available. when a new tenant instance is created, a new tent database should be created and the default database migration should be performed. this step happens for every new instance created. the new tenant databases contain all the data related to the tenants instance and are named like tenant_db_1, tenant_db_2, tenant_db_3, etc.. an overview of all available instances is kept in a table inside the accounting_db.

when a user logs in, i want to select the instance_id he belongs to from the accounting_db and open up a second db connection to his assigned tenant_db_x.

is tenanti capable of achieving this and how would i perform the according (second) tenant database connection after a user logs in? maybe i need a middleware?

thanks in advance

crynobone commented 9 years ago

I believe this reply already cover some of the basic stuff regarding multi-db

https://laracasts.com/discuss/channels/general-discussion/better-way-to-create-db-connect-on-the-fly?page=1#reply-69945

ghost commented 9 years ago

thank you, much appreciated