1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 02:04:03 +00:00

Make DB storage driver prefix sqlite DBs with database_path()

This commit is contained in:
Samuel Štancl 2019-08-17 21:56:30 +02:00
parent f87c2b69ec
commit 5edf582269
2 changed files with 17 additions and 3 deletions

View file

@ -89,9 +89,11 @@ final class DatabaseManager
}
}
public function getDriver(): ?string
public function getDriver($connectionName = null): ?string
{
return config('database.connections.tenant.driver');
$connectionName = $connectionName ?: $this->defaultTenantConnectionName;
return config("database.connections.$connectionName.driver");
}
public function createTenantConnection(string $databaseName, string $connectionName = null)
@ -105,7 +107,7 @@ final class DatabaseManager
]);
// Change DB name
$databaseName = $this->getDriver() === 'sqlite' ? database_path($databaseName) : $databaseName;
$databaseName = $this->getDriver($connectionName) === 'sqlite' ? database_path($databaseName) : $databaseName;
config()->set(["database.connections.$connectionName.database" => $databaseName]);
}