mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 15:14:04 +00:00
Set Internal DB Connection Name
This commit is contained in:
parent
20e1fa1959
commit
77248089af
1 changed files with 7 additions and 1 deletions
|
|
@ -78,6 +78,11 @@ class DatabaseConfig
|
|||
return $this->tenant->getInternal('db_password') ?? null;
|
||||
}
|
||||
|
||||
public function getDbConnectionName(): ?string
|
||||
{
|
||||
return $this->tenant->getInternal('db_connection') ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate DB name, username & password and write them to the tenant model.
|
||||
*
|
||||
|
|
@ -86,6 +91,7 @@ class DatabaseConfig
|
|||
public function makeCredentials(): void
|
||||
{
|
||||
$this->tenant->setInternal('db_name', $this->getName() ?? (static::$databaseNameGenerator)($this->tenant));
|
||||
$this->tenant->setInternal('db_connection', $this->getTemplateConnectionName());
|
||||
|
||||
if ($this->manager() instanceof ManagesDatabaseUsers) {
|
||||
$this->tenant->setInternal('db_username', $this->getUsername() ?? (static::$usernameGenerator)($this->tenant));
|
||||
|
|
@ -99,7 +105,7 @@ class DatabaseConfig
|
|||
|
||||
public function getTemplateConnectionName(): string
|
||||
{
|
||||
return $this->tenant->getInternal('db_connection')
|
||||
return $this->getDbConnectionName()
|
||||
?? config('tenancy.database.template_tenant_connection')
|
||||
?? config('tenancy.database.central_connection');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue