mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
merge
This commit is contained in:
commit
9ff77d2128
2 changed files with 4 additions and 2 deletions
|
|
@ -105,7 +105,8 @@ final class DatabaseManager
|
||||||
config()->set(['database.connections.tenant.database' => $database_name]);
|
config()->set(['database.connections.tenant.database' => $database_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function useConnection(string $connection) {
|
public function useConnection(string $connection)
|
||||||
|
{
|
||||||
$this->database->setDefaultConnection($connection);
|
$this->database->setDefaultConnection($connection);
|
||||||
$this->database->reconnect($connection);
|
$this->database->reconnect($connection);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ class TenantManagerEventsTest extends TestCase
|
||||||
Tenancy::bootstrapping(function ($tenancy) use ($uuid) {
|
Tenancy::bootstrapping(function ($tenancy) use ($uuid) {
|
||||||
if ($tenancy->tenant['uuid'] === $uuid) {
|
if ($tenancy->tenant['uuid'] === $uuid) {
|
||||||
$tenancy->database->useConnection('tenantabc');
|
$tenancy->database->useConnection('tenantabc');
|
||||||
|
|
||||||
return ['database'];
|
return ['database'];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -133,4 +134,4 @@ class TenantManagerEventsTest extends TestCase
|
||||||
tenancy()->init('abc.localhost');
|
tenancy()->init('abc.localhost');
|
||||||
$this->assertSame('tenant', \DB::connection()->getConfig()['name']);
|
$this->assertSame('tenant', \DB::connection()->getConfig()['name']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue