@@ -476,7 +476,7 @@ protected function mutateAttribute($key, $value)
476
476
protected function mutateAttributeForArray ($ key , $ value )
477
477
{
478
478
$ value = $ this ->isClassCastable ($ key )
479
- ? $ this ->getClassCastableAttributeValue ($ key )
479
+ ? $ this ->getClassCastableAttributeValue ($ key, $ value )
480
480
: $ this ->mutateAttribute ($ key , $ value );
481
481
482
482
return $ value instanceof Arrayable ? $ value ->toArray () : $ value ;
@@ -540,7 +540,7 @@ protected function castAttribute($key, $value)
540
540
}
541
541
542
542
if ($ this ->isClassCastable ($ key )) {
543
- return $ this ->getClassCastableAttributeValue ($ key );
543
+ return $ this ->getClassCastableAttributeValue ($ key, $ value );
544
544
}
545
545
546
546
return $ value ;
@@ -550,18 +550,19 @@ protected function castAttribute($key, $value)
550
550
* Cast the given attribute using a custom cast class.
551
551
*
552
552
* @param string $key
553
+ * @param mixed $value
553
554
* @return mixed
554
555
*/
555
- protected function getClassCastableAttributeValue ($ key )
556
+ protected function getClassCastableAttributeValue ($ key, $ value )
556
557
{
557
558
if (isset ($ this ->classCastCache [$ key ])) {
558
559
return $ this ->classCastCache [$ key ];
559
560
} else {
560
561
$ caster = $ this ->resolveCasterClass ($ key );
561
562
562
563
return $ this ->classCastCache [$ key ] = $ caster instanceof CastsInboundAttributes
563
- ? ( $ this -> attributes [ $ key ] ?? null )
564
- : $ caster ->get ($ this , $ key , $ this -> attributes [ $ key ] ?? null , $ this ->attributes );
564
+ ? $ value
565
+ : $ caster ->get ($ this , $ key , $ value , $ this ->attributes );
565
566
}
566
567
}
567
568
0 commit comments