1
0
Fork 0
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:
amirakbulut 2020-08-03 14:29:11 +02:00 committed by GitHub
parent a002f59420
commit df34a9eab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,8 +11,8 @@ trait GeneratesIds
public static function bootGeneratesIds()
{
static::creating(function (self $model) {
if (! $model->getTenantKey() && $model->shouldGenerateId()) {
$model->setAttribute($model->getTenantKeyName(), app(UniqueIdentifierGenerator::class)->generate($model));
if (! $model->getKey() && $model->shouldGenerateId()) {
$model->setAttribute($model->getKeyName(), app(UniqueIdentifierGenerator::class)->generate($model));
}
});
}