mirror of
https://github.com/archtechx/tenancy.git
synced 2026-06-21 03:04:04 +00:00
Improve annotations
Add newline after @var tenant annotation, make usage of`DB::getDatabaseName clearer.
This commit is contained in:
parent
c9fa41111d
commit
028b985e54
1 changed files with 3 additions and 1 deletions
|
|
@ -90,6 +90,7 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
||||||
protected function verifyTenantCanUseDatabase(Tenant $tenant): void
|
protected function verifyTenantCanUseDatabase(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
/** @var \Stancl\Tenancy\Database\Models\Tenant&TenantWithDatabase $tenant */
|
/** @var \Stancl\Tenancy\Database\Models\Tenant&TenantWithDatabase $tenant */
|
||||||
|
|
||||||
$tenantDbName = $tenant->database()->getName();
|
$tenantDbName = $tenant->database()->getName();
|
||||||
|
|
||||||
// Check that no other tenant uses this tenant's database
|
// Check that no other tenant uses this tenant's database
|
||||||
|
|
@ -99,12 +100,13 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
||||||
throw new RuntimeException('Tenant cannot use a database of another tenant.');
|
throw new RuntimeException('Tenant cannot use a database of another tenant.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the current database is not the central database
|
|
||||||
$centralDbName = DB::connection(
|
$centralDbName = DB::connection(
|
||||||
config('tenancy.database.central_connection', 'central')
|
config('tenancy.database.central_connection', 'central')
|
||||||
)->getDatabaseName();
|
)->getDatabaseName();
|
||||||
|
|
||||||
if (DB::getDatabaseName() === $centralDbName) {
|
if (DB::getDatabaseName() === $centralDbName) {
|
||||||
|
// Throw if the current database is central.
|
||||||
|
// DB::getDatabaseName() is the current DB name, which should not be central at this point.
|
||||||
throw new RuntimeException('Tenant cannot use the central database.');
|
throw new RuntimeException('Tenant cannot use the central database.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue