diff --git a/src/DatabaseManager.php b/src/DatabaseManager.php index 684bb1f7..df834a80 100644 --- a/src/DatabaseManager.php +++ b/src/DatabaseManager.php @@ -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. * diff --git a/src/TenantManager.php b/src/TenantManager.php index 5e080cb9..688d3cca 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -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(); }