From cffdb3e57d57815d597114042aed82478fd25ce2 Mon Sep 17 00:00:00 2001 From: amirakbulut Date: Mon, 3 Aug 2020 14:20:34 +0200 Subject: [PATCH] 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. --- src/Database/Concerns/GeneratesIds.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Database/Concerns/GeneratesIds.php b/src/Database/Concerns/GeneratesIds.php index 4779c237..75264abb 100644 --- a/src/Database/Concerns/GeneratesIds.php +++ b/src/Database/Concerns/GeneratesIds.php @@ -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)); } }); }