mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 07:14:04 +00:00
refactore name
This commit is contained in:
parent
8bbf92aa9b
commit
d6947f8058
1 changed files with 5 additions and 4 deletions
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy\Bootstrappers;
|
namespace Stancl\Tenancy\Bootstrappers;
|
||||||
|
|
||||||
use Illuminate\Bus\DatabaseBatchRepository;
|
use Illuminate\Bus\DatabaseBatchRepository;
|
||||||
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Contracts\Tenant;
|
use Stancl\Tenancy\Contracts\Tenant;
|
||||||
|
|
@ -18,22 +19,22 @@ class BatchTenancyBootstrapper implements TenancyBootstrapper
|
||||||
*/
|
*/
|
||||||
protected $previousConnection = null;
|
protected $previousConnection = null;
|
||||||
|
|
||||||
public function __construct(protected DatabaseBatchRepository $databaseBatchRepository)
|
public function __construct(protected DatabaseBatchRepository $batchRepository)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bootstrap(Tenant $tenant)
|
public function bootstrap(Tenant $tenant)
|
||||||
{
|
{
|
||||||
// Update batch repository connection to use the tenant connection
|
// Update batch repository connection to use the tenant connection
|
||||||
$this->previousConnection = $this->databaseBatchRepository->getConnection();
|
$this->previousConnection = $this->batchRepository->getConnection();
|
||||||
$this->databaseBatchRepository->setConnection(DB::connection('tenant'));
|
$this->batchRepository->setConnection(DB::connection('tenant'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function revert()
|
public function revert()
|
||||||
{
|
{
|
||||||
if ($this->previousConnection) {
|
if ($this->previousConnection) {
|
||||||
// Replace batch repository connection with the previously replaced one
|
// Replace batch repository connection with the previously replaced one
|
||||||
$this->databaseBatchRepository->setConnection($this->previousConnection);
|
$this->batchRepository->setConnection($this->previousConnection);
|
||||||
$this->previousConnection = null;
|
$this->previousConnection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue