mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
Use getTenantKey() instead of ->id references
This commit is contained in:
parent
d7536ce0af
commit
ac58f6992b
8 changed files with 15 additions and 15 deletions
|
|
@ -9,8 +9,8 @@ trait GeneratesIds
|
|||
public static function bootGeneratesIds()
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
if (! $model->id && app()->bound(UniqueIdentifierGenerator::class)) {
|
||||
$model->id = app(UniqueIdentifierGenerator::class)->generate($model);
|
||||
if (! $model->getTenantKey() && app()->bound(UniqueIdentifierGenerator::class)) {
|
||||
$model->setAttribute($model->getTenantKeyName(), app(UniqueIdentifierGenerator::class)->generate($model));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Tenant extends Model implements Contracts\Tenant
|
|||
return 'id';
|
||||
}
|
||||
|
||||
public function getTenantKey(): string
|
||||
public function getTenantKey(): ?string
|
||||
{
|
||||
return $this->getAttribute($this->getTenantKeyName());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue