How to change the Laravel 4.2 Auth database?

0

My project has two databases: one bank for user accounts and one for the project domain. My need is to define the database that Auth uses for authentication, because in the default configuration the domain database is defined.

return array(

'default' => 'mysql_domain', 

I wanted to change this setting to Auth so that it does not use the domain database.

'connections' => array(

    'mysql_account' => array(
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'user_agro_admin',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

    'mysql_domain' => array(
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'indicator_agro_admin',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    )

),

In the configuration of auth you can only define the driver, model and table. My need could be solved only if there was the Auth::setDefaultConnection('mysql_account') method or something similar. How to do this?

Q.: I do not want to change the default setting with the Config::set('database.fo', 'bar') method, but rather change the database that Auth uses!

Q.2: I use Query Builder.

    
asked by anonymous 12.01.2016 / 21:35

1 answer

1

Could not you just change the connection in the User model? According to the Eloquent documentation, you can do this:

protected $connection = 'connection-name';
    
12.01.2016 / 22:11