diff --git a/src/Bootstrappers/BatchTenancyBootstrapper.php b/src/Bootstrappers/BatchTenancyBootstrapper.php index ce891955..7f04d62b 100644 --- a/src/Bootstrappers/BatchTenancyBootstrapper.php +++ b/src/Bootstrappers/BatchTenancyBootstrapper.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Stancl\Tenancy\Bootstrappers; -use Illuminate\Bus\BatchRepository; use Illuminate\Bus\DatabaseBatchRepository; use Illuminate\Support\Facades\DB; use Stancl\Tenancy\Contracts\TenancyBootstrapper; @@ -19,24 +18,22 @@ class BatchTenancyBootstrapper implements TenancyBootstrapper */ protected $previousConnection = null; - public function __construct(protected BatchRepository $batchRepository) + public function __construct(protected DatabaseBatchRepository $databaseBatchRepository) { } public function bootstrap(Tenant $tenant) { - if ($this->batchRepository instanceof DatabaseBatchRepository) { - // Update batch repository connection to use the tenant connection - $this->previousConnection = $this->batchRepository->getConnection(); - $this->batchRepository->setConnection(DB::connection('tenant')); - } + // Update batch repository connection to use the tenant connection + $this->previousConnection = $this->databaseBatchRepository->getConnection(); + $this->databaseBatchRepository->setConnection(DB::connection('tenant')); } public function revert() { if ($this->previousConnection) { // Replace batch repository connection with the previously replaced one - $this->batchRepository->setConnection($this->previousConnection); + $this->databaseBatchRepository->setConnection($this->previousConnection); $this->previousConnection = null; } }