Skip to content

Commit

Permalink
Allow for multiple Tenant ID's to be included
Browse files Browse the repository at this point in the history
Fix for multiple tenants - hipsterjazzbo#86
Allow for multiple Tenant ID's to be included - hipsterjazzbo#53
  • Loading branch information
pjeutr authored Mar 19, 2019
1 parent 56468a3 commit 89f2d72
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/TenantManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,14 @@ public function applyTenantScopes(Model $model)

$this->modelTenants($model)->each(function ($id, $tenant) use ($model) {
$model->addGlobalScope($tenant, function (Builder $builder) use ($tenant, $id, $model) {
if ($this->getTenants()->first() && $this->getTenants()->first() != $id) {
$id = $this->getTenants()->first();
// Fix for multiple tenants - https://github.com/hipsterjazzbo/Landlord/pull/86/
// Allow for multiple Tenant ID's to be included - https://github.com/HipsterJazzbo/Landlord/pull/53
$id = $this->getTenantId($tenant);
if (is_array($id)) {
$builder->whereIn($model->getQualifiedTenant($tenant), $id);
} else {
$builder->where($model->getQualifiedTenant($tenant), '=', $id);
}

$builder->where($model->getQualifiedTenant($tenant), '=', $id);
});
});
}
Expand All @@ -168,11 +171,14 @@ public function applyTenantScopesToDeferredModels()
}

$model->addGlobalScope($tenant, function (Builder $builder) use ($tenant, $id, $model) {
if ($this->getTenants()->first() && $this->getTenants()->first() != $id) {
$id = $this->getTenants()->first();
// Fix for multiple tenants - https://github.com/hipsterjazzbo/Landlord/pull/86/
// Allow for multiple Tenant ID's to be included - https://github.com/HipsterJazzbo/Landlord/pull/53
$id = $this->getTenantId($tenant);
if (is_array($id)) {
$builder->whereIn($model->getQualifiedTenant($tenant), $id);
} else {
$builder->where($model->getQualifiedTenant($tenant), '=', $id);
}

$builder->where($model->getQualifiedTenant($tenant), '=', $id);
});
});
});
Expand Down

0 comments on commit 89f2d72

Please sign in to comment.