1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-21 04:04:03 +00:00

Improve annotations

Add newline after @var tenant annotation, make usage of`DB::getDatabaseName clearer.
This commit is contained in:
lukinovec 2026-06-10 07:56:30 +02:00
parent c9fa41111d
commit 028b985e54

View file

@ -90,6 +90,7 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
protected function verifyTenantCanUseDatabase(Tenant $tenant): void
{
/** @var \Stancl\Tenancy\Database\Models\Tenant&TenantWithDatabase $tenant */
$tenantDbName = $tenant->database()->getName();
// 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.');
}
// Check that the current database is not the central database
$centralDbName = DB::connection(
config('tenancy.database.central_connection', 'central')
)->getDatabaseName();
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.');
}
}