You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please i wanna more details how this function work
protectedfunctionsetTenantConnectionDatabaseName(?string$databaseName)
{
$tenantConnectionName = $this->tenantDatabaseConnectionName();
if ($tenantConnectionName === $this->landlordDatabaseConnectionName()) {
throw InvalidConfiguration::tenantConnectionIsEmptyOrEqualsToLandlordConnection();
}
if (is_null(config("database.connections.{$tenantConnectionName}"))) {
throw InvalidConfiguration::tenantConnectionDoesNotExist($tenantConnectionName);
}
config([
"database.connections.{$tenantConnectionName}.database" => $databaseName,
]); here i set the new configration
app('db')->extend($tenantConnectionName, function ($config, $name) use ($databaseName) {
$config['database'] = $databaseName;
returnapp('db.factory')->make($config, $name);
}); why make an instance dbmanager with a new configuration even though I set it in config database fileand i will purge=> disconnect and clear cache
DB::purge($tenantConnectionName);
// Octane will have an old `db` instance in the Model::$resolver.
Model::setConnectionResolver(app('db')); why this even though i purge mean ensure why the models will use the old config from cache
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Please i wanna more details how this function work
Beta Was this translation helpful? Give feedback.
All reactions