Skip to content

Commit 028b985

Browse files
committed
Improve annotations
Add newline after @var tenant annotation, make usage of`DB::getDatabaseName clearer.
1 parent c9fa411 commit 028b985

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Bootstrappers/DatabaseTenancyBootstrapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function revert(): void
9090
protected function verifyTenantCanUseDatabase(Tenant $tenant): void
9191
{
9292
/** @var \Stancl\Tenancy\Database\Models\Tenant&TenantWithDatabase $tenant */
93+
9394
$tenantDbName = $tenant->database()->getName();
9495

9596
// Check that no other tenant uses this tenant's database
@@ -99,12 +100,13 @@ protected function verifyTenantCanUseDatabase(Tenant $tenant): void
99100
throw new RuntimeException('Tenant cannot use a database of another tenant.');
100101
}
101102

102-
// Check that the current database is not the central database
103103
$centralDbName = DB::connection(
104104
config('tenancy.database.central_connection', 'central')
105105
)->getDatabaseName();
106106

107107
if (DB::getDatabaseName() === $centralDbName) {
108+
// Throw if the current database is central.
109+
// DB::getDatabaseName() is the current DB name, which should not be central at this point.
108110
throw new RuntimeException('Tenant cannot use the central database.');
109111
}
110112
}

0 commit comments

Comments
 (0)