mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 13:54:03 +00:00
Modified GeneratesIds.php (#472)
* Modified GeneratesIds.php When overwriting `getTenantKeyName()` to use another column, an exception occurs when creating new tenants. (Field 'id' doesn't have a default value). This fixes the issue. * Fix style Co-authored-by: Samuel Stancl <samuel.stancl@gmail.com>
This commit is contained in:
parent
a002f59420
commit
df34a9eab9
1 changed files with 2 additions and 2 deletions
|
|
@ -11,8 +11,8 @@ trait GeneratesIds
|
||||||
public static function bootGeneratesIds()
|
public static function bootGeneratesIds()
|
||||||
{
|
{
|
||||||
static::creating(function (self $model) {
|
static::creating(function (self $model) {
|
||||||
if (! $model->getTenantKey() && $model->shouldGenerateId()) {
|
if (! $model->getKey() && $model->shouldGenerateId()) {
|
||||||
$model->setAttribute($model->getTenantKeyName(), app(UniqueIdentifierGenerator::class)->generate($model));
|
$model->setAttribute($model->getKeyName(), app(UniqueIdentifierGenerator::class)->generate($model));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue