Skip to content

Commit

Permalink
Fix of multiple tenants
Browse files Browse the repository at this point in the history
Fix of multiple tenants hipsterjazzbo#85
  • Loading branch information
aluferraz committed Nov 21, 2017
1 parent 8c2a15a commit be84d0b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/TenantManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand All @@ -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);
});
Expand Down

0 comments on commit be84d0b

Please sign in to comment.