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
Post a Comment