From c8d6e64f7edd30a0315747f3fb3d16294ec8dfd6 Mon Sep 17 00:00:00 2001 From: Bastien Philippe Date: Tue, 19 Dec 2023 08:54:02 +0100 Subject: [PATCH] Add a boolean to Attribute in order to define if it is nullable in database --- src/Domain/Models/Actions/ResolveModelAttributes.php | 1 + src/Domain/Models/Entities/Attribute.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Domain/Models/Actions/ResolveModelAttributes.php b/src/Domain/Models/Actions/ResolveModelAttributes.php index 7caf46f..880b521 100644 --- a/src/Domain/Models/Actions/ResolveModelAttributes.php +++ b/src/Domain/Models/Actions/ResolveModelAttributes.php @@ -20,6 +20,7 @@ public function execute(Model $model): void $attribute->inDatabase = true; if (!$column->getNotnull() && !$this->isLaravelTimestamp($model, $attribute)) { $attribute->nullable = true; + $attribute->nullableInDatabase = true; } $model->addAttribute($typeCaster->resolve($attribute)); diff --git a/src/Domain/Models/Entities/Attribute.php b/src/Domain/Models/Entities/Attribute.php index 8503930..58c59ec 100644 --- a/src/Domain/Models/Entities/Attribute.php +++ b/src/Domain/Models/Entities/Attribute.php @@ -18,6 +18,8 @@ class Attribute public bool $inDatabase = false; + public bool $nullableInDatabase = false; + public ?string $comment = null; public function __construct(string $name, string $type)