mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:34:03 +00:00
Fix initialize() method (#488)
* Fix initialize() method * Remove useless line
This commit is contained in:
parent
36aabb7883
commit
5fe79fea33
1 changed files with 10 additions and 12 deletions
|
|
@ -31,6 +31,15 @@ class Tenancy
|
||||||
*/
|
*/
|
||||||
public function initialize($tenant): void
|
public function initialize($tenant): void
|
||||||
{
|
{
|
||||||
|
if (! is_object($tenant)) {
|
||||||
|
$tenantId = $tenant;
|
||||||
|
$tenant = $this->find($tenantId);
|
||||||
|
|
||||||
|
if (! $tenant) {
|
||||||
|
throw new TenantCountNotBeIdentifiedById($tenantId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->initialized && $this->tenant->getTenantKey() === $tenant->getTenantKey()) {
|
if ($this->initialized && $this->tenant->getTenantKey() === $tenant->getTenantKey()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -40,18 +49,7 @@ class Tenancy
|
||||||
$this->end();
|
$this->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_object($tenant)) {
|
$this->tenant = $tenant;
|
||||||
$this->tenant = $tenant;
|
|
||||||
} else {
|
|
||||||
$tenantId = $tenant;
|
|
||||||
$tenant = $this->find($tenantId);
|
|
||||||
|
|
||||||
if (! $tenant) {
|
|
||||||
throw new TenantCountNotBeIdentifiedById($tenantId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->tenant = $tenant;
|
|
||||||
}
|
|
||||||
|
|
||||||
event(new Events\InitializingTenancy($this));
|
event(new Events\InitializingTenancy($this));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue