10000 Fixed casting datetime attribute and fixed test · laravel/framework@14cecbb · GitHub
[go: up one dir, main page]

Skip to content

Commit 14cecbb

Browse files
author
Andrey Helldar
committed
Fixed casting datetime attribute and fixed test
1 par
8000
ent 4f5b00d commit 14cecbb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt
118118
// If the attribute cast was a date or a datetime, we will serialize the date as
119119
// a string. This allows the developers to customize how dates are serialized
120120
// into an array without affecting how they are persisted into the storage.
121-
if (($value === 'date' || $value === 'datetime')) {
121+
if ($attributes[$key] &&
122+
($value === 'date' || $value === 'datetime')) {
122123
$attributes[$key] = $this->serializeDate($attributes[$key]);
123124
}
124125

tests/Integration/Database/EloquentModelCustomCastingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class StringCast implements Castable
7676
{
7777
public function get($value)
7878
{
79-
return mb_str_split($value);
79+
return str_split($value);
8080
}
8181

8282
public function set($value)

0 commit comments

Comments
 (0)
0