Skip to content

Commit bad0d42

Browse files
committed
Pass attribute key to object for reusability
1 parent 1dcfce2 commit bad0d42

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ protected function castToClass($key)
534534
return $this->classCastCache[$key];
535535
} else {
536536
return $this->classCastCache[$key] = forward_static_call(
537-
[$this->getCasts()[$key], 'fromModelAttributes'], $this, $this->attributes
537+
[$this->getCasts()[$key], 'fromModelAttributes'], $this->attributes, $key, $this
538538
);
539539
}
540540
}
@@ -565,7 +565,8 @@ protected function mergeAttributesFromClassCasts()
565565
{
566566
foreach ($this->classCastCache as $key => $value) {
567567
$this->attributes = array_merge(
568-
$this->attributes, $value->toModelAttributes($this, $this->attributes)
568+
$this->attributes,
569+
$value->toModelAttributes($this->attributes, $key, $this)
569570
);
570571
}
571572
}
@@ -640,7 +641,7 @@ protected function setClassCastableAttribute($key, $value)
640641
function () {
641642
return;
642643
},
643-
$this->castToClass($key)->toModelAttributes($this)
644+
$this->castToClass($key)->toModelAttributes($this->attributes, $key, $this)
644645
));
645646

646647
unset($this->classCastCache[$key]);

0 commit comments

Comments
 (0)