当我在登录过程中动态更改数据库时,Auth Facade无法理解它,并且总是从默认数据库中获取用户。 除Auth门面外,所有其他功能均正常工作。 这是更改租户数据库的功能
function setDBConnection($params){
config(['database.connections.tenant' => [
'driver' => $params['driver'],
'host' => $params['host'],
'database' => $params['database'],
'username' => $params['username'],
'password' => $params['password'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]]);
DB::reconnect('tenant');
}
我的租户模型中有
protected $connection = 'tenant';
我也在使用中间件来保持连接。 请帮帮我,非常感谢!