Skip to content

Commit 442626c

Browse files
authored
change array_merge to array_replace to prevent reindex (#45309)
Fixes issue where array [506 => null, 'name' => 'kevin'] is reindexed as [0 => null, 'name' => 'kevin']
1 parent 28bd786 commit 442626c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ protected function setClassCastableAttribute($key, $value)
11191119
{
11201120
$caster = $this->resolveCasterClass($key);
11211121

1122-
$this->attributes = array_merge(
1122+
$this->attributes = array_replace(
11231123
$this->attributes,
11241124
$this->normalizeCastClassResponse($key, $caster->set(
11251125
$this, $key, $value, $this->attributes

0 commit comments

Comments
 (0)