Laravel - change the default database connection globally

后端 未结 2 427
再見小時候
再見小時候 2020-12-29 13:29

In my database.php, I have TWO databases configured.

\'db1\' => array(
  \'driver\'   => \'pgsql\',
  \'host\'     => \'localhost\',
           


        
2条回答
  •  执念已碎
    2020-12-29 14:02

    Have you tried simply to change the default connection in app/config/database.php?

    'default' => 'db2'
    

    If it's not the case then please provide more information on the problem.

    Edit: So it seems you have all connections hardcoded in the models. Try updating the models like that:

        protected $connection = 'db2';
    

提交回复
热议问题