mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
Add event prevents, Tenant facade
This commit is contained in:
parent
1a88cad4d6
commit
4aa35322da
9 changed files with 187 additions and 97 deletions
|
|
@ -6,7 +6,7 @@ use Stancl\Tenancy\Jobs\QueuedTenantDatabaseCreator;
|
|||
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseDeleter;
|
||||
use Illuminate\Database\DatabaseManager as BaseDatabaseManager;
|
||||
|
||||
class DatabaseManager
|
||||
final class DatabaseManager
|
||||
{
|
||||
public $originalDefaultConnection;
|
||||
|
||||
|
|
@ -19,8 +19,7 @@ class DatabaseManager
|
|||
public function connect(string $database)
|
||||
{
|
||||
$this->createTenantConnection($database);
|
||||
$this->database->setDefaultConnection('tenant');
|
||||
$this->database->reconnect('tenant');
|
||||
$this->useConnection('tenant');
|
||||
}
|
||||
|
||||
public function connectToTenant($tenant)
|
||||
|
|
@ -105,4 +104,9 @@ class DatabaseManager
|
|||
$database_name = $this->getDriver() === 'sqlite' ? database_path($database_name) : $database_name;
|
||||
config()->set(['database.connections.tenant.database' => $database_name]);
|
||||
}
|
||||
|
||||
public function useConnection(string $connection) {
|
||||
$this->database->setDefaultConnection($connection);
|
||||
$this->database->reconnect($connection);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue