We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c125406 commit 65c2f0aCopy full SHA for 65c2f0a
src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
@@ -568,9 +568,9 @@ protected function mergeAttributesFromClassCasts()
568
$attributeCount = count($attributes);
569
$object = $this->castToClass($attribute);
570
571
- $castedAttributes = method_exists($object, '__toString')
572
- ? (string) $object
573
- : $this->{'castFrom'.Str::studly($type)}($object);
+ $castedAttributes = method_exists($this, 'castFrom'.Str::studly($type))
+ ? $this->{'castFrom'.Str::studly($type)}($object)
+ : $object->__toString();
574
575
if ($attributeCount !== count($castedAttributes)) {
576
throw new LogicException("Class cast {$attribute} must return {$attributeCount} attributes");
0 commit comments