laravel Change Database connection run time

前端 未结 4 1775
-上瘾入骨i
-上瘾入骨i 2020-12-24 14:48

I need to change laravel 5 database connection in run time.

Do you have any idea about it?

Please share with me.

Thanks.

4条回答
  •  醉话见心
    2020-12-24 15:10

    You can change it like this since Laravel 5.x or 6.x

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

    Where databasename has to be specified in config/database in the connections array.

提交回复
热议问题