laravel - Call Config::set to change database in Lumen 5.4? (Using Eloquent) -




i have small application in lumen should handle multiple databases based on request url. make possible in first place i've created folder /config/ , config-file called /config/database.php. here code , added comments show need do.

<?php return [     'migrations' => 'home',     'default' => 'home',     'connections' => [         // default option , needed check if "client" exists.         'home' => [             'driver'    => 'mysql',             'host'      => 'localhost',             'database'  => 'home',             'username'  => 'root',             'password'  => 'password',             'charset'   => 'utf8',             'collation' => 'utf8_unicode_ci',             'prefix'    => '',             'strict'    => false,         ],              // when client found in "home" connection, i'd continue database settings default.         'client' => [             'driver'    => 'mysql',             'host'      => 'localhost',             'database'  => 'client_', // there 1 database per client in end this: "client_******", have add using config:set...             'username'  => 'root',             'password'  => 'password',             'charset'   => 'utf8',             'collation' => 'utf8_unicode_ci',             'prefix'    => '',             'strict'    => false,         ],     ], ]; 

i have call config::set change these settings doesnt seem available on lumen. how can change these settings (the default database connection , database)

i hope there way make possible. lot :)

i found solution.

to set , edit configuration use "config" helper method array argument.

example:

config(['database.default' => 'your_connection']); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -