diff --git a/src/SerializeBehavior.php b/src/SerializeBehavior.php index a152ab0..50a19b4 100644 --- a/src/SerializeBehavior.php +++ b/src/SerializeBehavior.php @@ -72,12 +72,12 @@ public function beforeSave() public function afterSave(AfterSaveEvent $event) { foreach ($this->data as $key => $_) { - $attribute = $this->attributes[$key] ?? null; - $old = $this->oldData[$key] ?? null; + $attribute = isset($this->attributes[$key]) ? $this->attributes[$key] : null; + $old = isset($this->oldData[$key]) ? $this->oldData[$key] : null; if ($old === null && $attribute !== null) { if ($attribute instanceof Closure || (is_array($attribute) && is_callable($attribute))) { - $old = call_user_func($attribute); + $old = $attribute(); } else { $old = $attribute; }