From 191a4bdfcf4654a8e36a54bde20839ce73667576 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Mon, 29 Jan 2024 15:14:00 -0500 Subject: [PATCH] fix Halcyon model --- src/Extension/ExtendableTrait.php | 3 +-- src/Halcyon/Model.php | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Extension/ExtendableTrait.php b/src/Extension/ExtendableTrait.php index 2855d1871..f899d6699 100644 --- a/src/Extension/ExtendableTrait.php +++ b/src/Extension/ExtendableTrait.php @@ -210,7 +210,6 @@ public function addDynamicProperty($dynamicName, $value = null) self::$extendableGuardProperties = false; array_set($this->extensionData['dynamicProperties'], $dynamicName, $value); - $this->extendableSet($dynamicName, $value); self::$extendableGuardProperties = true; } @@ -419,7 +418,7 @@ public function extendableSet($name, $value) * Setting an undefined property */ if (!self::$extendableGuardProperties) { - $this->{$name} = $value; + array_set($this->extensionData['dynamicProperties'], $name, $value); } } diff --git a/src/Halcyon/Model.php b/src/Halcyon/Model.php index c130823ad..4129f5bfe 100644 --- a/src/Halcyon/Model.php +++ b/src/Halcyon/Model.php @@ -1603,6 +1603,15 @@ public static function cacheMutatedAttributes($class) static::$mutatorCache[$class] = $mutatedAttributes; } + public function addDynamicProperty($dynamicName, $value = null) + { + if (isset($this->attributes[$dynamicName])) { + return; + } + + $this->setAttribute($dynamicName, $value); + } + /** * Dynamically retrieve attributes on the model. *