1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 23:14:05 +00:00

Resolve circular dependency

This commit is contained in:
Samuel Štancl 2019-10-27 18:56:43 +01:00
parent 540f1ee3d1
commit e872139c88
2 changed files with 15 additions and 3 deletions

View file

@ -28,14 +28,26 @@ class DatabaseManager
/** @var TenantManager */
protected $tenancy;
public function __construct(Application $app, BaseDatabaseManager $database, TenantManager $tenantManager)
public function __construct(Application $app, BaseDatabaseManager $database)
{
$this->app = $app;
$this->database = $database;
$this->tenancy = $tenantManager;
$this->originalDefaultConnectionName = $app['config']['database.default'];
}
/**
* Set the TenantManager instance, used to dispatch tenancy events.
*
* @param TenantManager $tenantManager
* @return self
*/
public function withTenantManager(TenantManager $tenantManager): self
{
$this->tenancy = $tenantManager;
return $this;
}
/**
* Connect to a tenant's database.
*

View file

@ -54,7 +54,7 @@ class TenantManager
$this->app = $app;
$this->storage = $storage;
$this->artisan = $artisan;
$this->database = $database;
$this->database = $database->withTenantManager($this);
$this->bootstrapFeatures();
}