Skip to content

Commit

Permalink
Mutate original values
Browse files Browse the repository at this point in the history
  • Loading branch information
kchung committed Oct 15, 2024
1 parent 7ceb9b6 commit 3a8f426
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ public function attributesToArray()
return $attributes;
}

/**
* {@inheritdoc}
*/
public function getOriginal($key = null, $default = null)
{
$original = parent::getOriginal($key, $default);

if ($key) {
if ($this->hasMutator($key)) {
return $this->unserializeAttribute($key, $original);
}

return $original;
}

foreach ($original as $attribute => $value) {
if ($this->hasMutator($attribute)) {
$original[$attribute] = $this->unserializeAttribute($attribute, $value);
}
}

return $original;
}

/**
* Define a many-to-many relationship.
*
Expand Down

0 comments on commit 3a8f426

Please sign in to comment.