1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 16:44:04 +00:00

Refactor DB config & Tenant DB managers

This commit is contained in:
Samuel Štancl 2020-05-12 03:32:28 +02:00
parent 3c4d2189dc
commit 64383b4c56
8 changed files with 51 additions and 41 deletions

View file

@ -102,19 +102,11 @@ class DatabaseConfig
public function connection(): array
{
$template = $this->getTemplateConnectionName();
$templateConnection = config("database.connections.{$template}");
// todo move a lot of this logic to the tenant DB manager so that we dont have to deal with the separators & modifying DB names here
$databaseName = $this->getName();
if (($manager = $this->manager()) instanceof ModifiesDatabaseNameForConnection) {
/** @var ModifiesDatabaseNameForConnection $manager */
$databaseName = $manager->getDatabaseNameForConnection($databaseName);
}
return array_merge($templateConnection, $this->tenantConfig(), [
$this->manager()->getSeparator() => $databaseName,
]);
return $this->manager()->makeConnectionConfig(
array_merge($templateConnection, $this->tenantConfig()), $this->getName()
);
}
/**