mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 17:24:03 +00:00
better defaults
This commit is contained in:
parent
6c5bde7d07
commit
1d42f33d34
6 changed files with 34 additions and 14 deletions
|
|
@ -10,6 +10,7 @@ use Illuminate\Database\DatabaseManager;
|
|||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
|
||||
// todo add docblock
|
||||
class BatchTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ use Illuminate\Support\Facades\Cache;
|
|||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
|
||||
// todo@rename some bootstrappers end in TenancyBootstrapper and others don't - make this consistent or make the difference clear
|
||||
|
||||
/**
|
||||
* todo@name rename?
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,14 +30,18 @@ class SessionTenancyBootstrapper implements TenancyBootstrapper
|
|||
|
||||
public function bootstrap(Tenant $tenant): void
|
||||
{
|
||||
$this->resetDatabaseHandler();
|
||||
if ($this->config->get('session.driver') === 'database') {
|
||||
$this->resetDatabaseHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public function revert(): void
|
||||
{
|
||||
// When ending tenancy, this runs *before* the DatabaseTenancyBootstrapper, so DB tenancy
|
||||
// is still bootstrapped. For that reason, we have to explicitly use the central connection
|
||||
$this->resetDatabaseHandler(config('tenancy.database.central_connection'));
|
||||
if ($this->config->get('session.driver') === 'database') {
|
||||
// When ending tenancy, this runs *before* the DatabaseTenancyBootstrapper, so DB tenancy
|
||||
// is still bootstrapped. For that reason, we have to explicitly use the central connection
|
||||
$this->resetDatabaseHandler(config('tenancy.database.central_connection'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function resetDatabaseHandler(string $defaultConnection = null): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue