Skip to content

Commit 2d52abc

Browse files
committed
fix custom class cast with dates
1 parent fd6d109 commit 2d52abc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt
231231
$attributes[$key] = $attributes[$key]->format(explode(':', $value, 2)[1]);
232232
}
233233

234+
if ($attributes[$key] && $attributes[$key] instanceof DateTimeInterface &&
235+
$this->isClassCastable($key)) {
236+
$attributes[$key] = $this->serializeDate($attributes[$key]);
237+
}
238+
234239
if ($attributes[$key] instanceof Arrayable) {
235240
$attributes[$key] = $attributes[$key]->toArray();
236241
}

0 commit comments

Comments
 (0)