mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-16 10:44:05 +00:00
Refactor models & config
This commit is contained in:
parent
f0ff8248e7
commit
2839f45196
9 changed files with 123 additions and 97 deletions
|
|
@ -11,7 +11,7 @@ trait GeneratesIds
|
|||
public static function bootGeneratesIds()
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
if (! $model->getTenantKey() && app()->bound(UniqueIdentifierGenerator::class)) {
|
||||
if (! $model->getTenantKey() && $model->shouldGenerateId()) {
|
||||
$model->setAttribute($model->getTenantKeyName(), app(UniqueIdentifierGenerator::class)->generate($model));
|
||||
}
|
||||
});
|
||||
|
|
@ -19,6 +19,11 @@ trait GeneratesIds
|
|||
|
||||
public function getIncrementing()
|
||||
{
|
||||
return ! app()->bound(UniqueIdentifierGenerator::class);
|
||||
return ! $this->shouldGenerateId();
|
||||
}
|
||||
|
||||
public function shouldGenerateId(): bool
|
||||
{
|
||||
return app()->bound(UniqueIdentifierGenerator::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue