From 3e27b1b7af86c0b3dfba97147cc95eccb9efc813 Mon Sep 17 00:00:00 2001 From: KJ Date: Mon, 23 Sep 2024 15:06:44 -0400 Subject: [PATCH] Allow null on enum properties. --- src/Libs/Model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Libs/Model.php b/src/Libs/Model.php index 3538ab2..9f611ab 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -250,7 +250,8 @@ class Model { foreach ($elem as $key => $value) { $index = array_search($key, $propertyNames); - if (is_numeric($index) && enum_exists($properties[$index]->getType()->getName())) + if (is_numeric($index) && isset($value) && + enum_exists($properties[$index]->getType()->getName())) $instance->$key = $properties[$index]->getType()->getName()::tryfrom($value); else $instance->$key = $value;