mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 23:34:03 +00:00
Refactor more old code and get tests to pass
This commit is contained in:
parent
c5377a16f7
commit
c32f229dd5
72 changed files with 425 additions and 531 deletions
|
|
@ -6,9 +6,7 @@ namespace Stancl\Tenancy;
|
|||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Stancl\Tenancy\Contracts\Future\CanSetConnection;
|
||||
use Stancl\Tenancy\Contracts\ManagesDatabaseUsers;
|
||||
use Stancl\Tenancy\Contracts\ModifiesDatabaseNameForConnection;
|
||||
use Stancl\Tenancy\Contracts\TenantDatabaseManager;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Exceptions\DatabaseManagerNotRegisteredException;
|
||||
|
|
@ -79,6 +77,11 @@ class DatabaseConfig
|
|||
return $this->tenant->getInternal('db_password') ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate DB name, username & password and write them to the tenant model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function makeCredentials(): void
|
||||
{
|
||||
$this->tenant->setInternal('db_name', $this->getName() ?? (static::$databaseNameGenerator)($this->tenant));
|
||||
|
|
@ -151,9 +154,7 @@ class DatabaseConfig
|
|||
/** @var TenantDatabaseManager $databaseManager */
|
||||
$databaseManager = app($databaseManagers[$driver]);
|
||||
|
||||
if ($databaseManager instanceof CanSetConnection) {
|
||||
$databaseManager->setConnection($this->getTemplateConnectionName());
|
||||
}
|
||||
$databaseManager->setConnection($this->getTemplateConnectionName());
|
||||
|
||||
return $databaseManager;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue