Support the ongoing development of Laravel.io →
posted 4 years ago

Hi to all, i'm new on the laravel world, i have a db with users and params for connect to user's db, and a db for each user. now when the user login i want to change the default db with the user's db. i have tried to override the default connection with params like this: Config::set("database.connections.mysql", [ "host" => "localhost", "driver" => "mysql", "default" => "mysql", "database" => $dati->db, "username" => "root", "password" => "" ]); DB::reconnect('mysql');
but it work only for the controller and model where i call the function.

there is a way to extends the new params to all model in the project?

thanks in advance.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Ciccios nexus6ita Joined 4 May 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.