From 2fcaaaee264c3ed442de37dde6ab0c3d9fad8a70 Mon Sep 17 00:00:00 2001 From: Kevin Dees Date: Wed, 14 Dec 2022 09:49:03 -0500 Subject: [PATCH] change array_merge to array_replace to prevent reindex Fixes issue where array [506 => null, 'name' => 'kevin'] is reindexed as [0 => null, 'name' => 'kevin'] --- src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 533e9d6c2176..4b787352cfc8 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -1119,7 +1119,7 @@ protected function setClassCastableAttribute($key, $value) { $caster = $this->resolveCasterClass($key); - $this->attributes = array_merge( + $this->attributes = array_replace( $this->attributes, $this->normalizeCastClassResponse($key, $caster->set( $this, $key, $value, $this->attributes