Skip to content

Commit

Permalink
Resolve archtechx#854
Browse files Browse the repository at this point in the history
  • Loading branch information
stancl authored May 15, 2022
1 parent 0569bf5 commit a1c3442
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Database/Concerns/BelongsToTenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ trait BelongsToTenant

public function tenant()
{
return $this->belongsTo(config('tenancy.tenant_model'), BelongsToTenant::$tenantIdColumn);
return $this->belongsTo(config('tenancy.tenant_model'), static::$tenantIdColumn);
}

public static function bootBelongsToTenant()
{
static::addGlobalScope(new TenantScope);

static::creating(function ($model) {
if (! $model->getAttribute(BelongsToTenant::$tenantIdColumn) && ! $model->relationLoaded('tenant')) {
if (! $model->getAttribute(static::$tenantIdColumn) && ! $model->relationLoaded('tenant')) {
if (tenancy()->initialized) {
$model->setAttribute(BelongsToTenant::$tenantIdColumn, tenant()->getTenantKey());
$model->setAttribute(static::$tenantIdColumn, tenant()->getTenantKey());
$model->setRelation('tenant', tenant());
}
}
Expand Down

0 comments on commit a1c3442

Please sign in to comment.