use Illuminate\Config\Repository;
public function __construct(Repository $config) {}
So now you can $config from the above reference.
Below is a sample usage of change database name:
$config->set("database.connections.mysql.database", "test");
or
app()->config->set("database.connections.mysql.database", "test");
You can use this functionality in middle-ware.
If your app already connected then you have to disconnect it before make new connection available.
Below follow steps to disconnect connection:
$dm = app("Illuminate\\Database\\DatabaseManager");
$dm->disconnect();
public function __construct(Repository $config) {}
So now you can $config from the above reference.
Below is a sample usage of change database name:
$config->set("database.connections.mysql.database", "test");
or
app()->config->set("database.connections.mysql.database", "test");
You can use this functionality in middle-ware.
If your app already connected then you have to disconnect it before make new connection available.
Below follow steps to disconnect connection:
$dm = app("Illuminate\\Database\\DatabaseManager");
$dm->disconnect();
No comments:
Post a Comment