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