diff --git a/Changelog.md b/Changelog.md index 4c2bd12..4e3a5fd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,10 @@ # Changelog ### Konekt Enum Eloquent -## 1.3.2 -##### 2019-09-17 +## Unreleased +##### 2019-XX-XX -- Added support for Eloquent `toArray()` +- Added support for Eloquent `toArray()` (enums field values are properly included) ## 1.3.1 ##### 2019-09-08 diff --git a/src/CastsEnums.php b/src/CastsEnums.php index 9412636..afd6f8c 100644 --- a/src/CastsEnums.php +++ b/src/CastsEnums.php @@ -4,6 +4,7 @@ * * @copyright Copyright (c) 2017 Attila Fulop * @author Attila Fulop + * @author Nick Rupert * @license MIT * @since 2017-10-05 * @@ -90,19 +91,13 @@ protected function isEnumAttribute($key) return isset($this->enums[$key]); } - /** - * Add enum values to the attributes array - * - * @param $array - * @return array - */ - protected function addEnumAttributesToArray($array) + protected function addEnumAttributesToArray(array $attributes): array { foreach ($this->enums as $key => $value) { - $array[$key] = $this->getAttributeValue($key)->value(); + $attributes[$key] = $this->getAttributeValue($key)->value(); } - return $array; + return $attributes; } /**