Easy way to change database on the fly #38664
-
Hi, I am rebuilding an existent php website, and transferring it to laravel. The existing website used a database per tenant plus a main database. Right now I had to jump through a few loops to get it working, namely I had to add a 'connectToSecondDatabase' middleware that calls the config helper function to change the second database credentials. This kinda works, but I also had to add the middleware priority array to the Kernel.php file. It all feels a bit too hacky and forced for functionality that seems pretty widely used (multi tenancy using a database per tenant). Couldn't laravel maybe implement something that would make this more easy? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Tenancy for Laravel is a great package for implementing multi-tenancy with laravel. |
Beta Was this translation helpful? Give feedback.
Tenancy for Laravel is a great package for implementing multi-tenancy with laravel.