Skip to content

Commit

Permalink
Minor polishes related to toArray() support
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Nov 3, 2019
1 parent 297971f commit d64c734
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 4 additions & 9 deletions src/CastsEnums.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* @copyright Copyright (c) 2017 Attila Fulop
* @author Attila Fulop
* @author Nick Rupert
* @license MIT
* @since 2017-10-05
*
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit d64c734

Please sign in to comment.