Hi i have been searching over the internet regarding using multiple database connections and found solutions that allows me to first create connection in database.php and then i can switch them whenever needed. Now the problem is i dont know about the database names on run time. I have a primary database for letting user login and then the database will determine which database to switch based on user log in.
What i have tried :
Config::set('database.connections.mysql.database', Config::get('database.connections.mysql.database') . '_business_' . $preUser->business_id);
This is what i did earlier and my code was working on local environment but when i switched to my dev environment it stopped working.
Any idea why
The other issue i am getting is i want to run migrations and seeding with this same scenario. I would have a series of databases in an array and will need to run migration on each of them.
I have also tried this solution but it does not work somehow. it shows null when i try to get my database connection after setting it
Artisan::call('migrate', ['--path' => '../plugins/'.$tag.'/migrations', '--force' => true]);