From 86a667cdc3a4810d6b3ef19ced30ec1e2269d87e Mon Sep 17 00:00:00 2001 From: Attila Fulop <1162360+fulopattila122@users.noreply.github.com> Date: Fri, 11 Mar 2022 20:16:07 +0100 Subject: [PATCH] Mutator calls other mutators before passing the value to the enum constructor --- Changelog.md | 6 ++++++ src/CastsEnums.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 1a8ec68..40bc78e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,12 @@ # Changelog ### Konekt Enum Eloquent +## Unreleased +##### 2022-03-XX + +- Changed casting behavior so that other mutators defined on field are also + being called before passing the value to the enum constructor + ## 1.8.0 ##### 2022-03-10 diff --git a/src/CastsEnums.php b/src/CastsEnums.php index d483b60..3eb6250 100644 --- a/src/CastsEnums.php +++ b/src/CastsEnums.php @@ -30,7 +30,7 @@ public function getAttributeValue($key) if ($this->isEnumAttribute($key)) { $class = $this->getEnumClass($key); - return $class::create($this->getAttributeFromArray($key)); + return $class::create(parent::getAttributeValue($key)); } return parent::getAttributeValue($key);