From be84d0b6325b90194510f0e934a0dbbcfca29c8a Mon Sep 17 00:00:00 2001 From: aluferraz Date: Tue, 21 Nov 2017 16:21:42 -0200 Subject: [PATCH] Fix of multiple tenants Fix of multiple tenants #85 --- src/TenantManager.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/TenantManager.php b/src/TenantManager.php index 4a719ae..c62cf60 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -142,10 +142,7 @@ 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(); - } - + $id = $this->getTenantId($tenant); $builder->where($model->getQualifiedTenant($tenant), '=', $id); }); }); @@ -164,9 +161,7 @@ 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(); - } + $id = $this->getTenantId($tenant); $builder->where($model->getQualifiedTenant($tenant), '=', $id); });