Skip to content

Commit 54713b3

Browse files
Swap multiple logical OR for in_array when checking date casting (#38307)
1 parent ec405fc commit 54713b3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt
244244
// If the attribute cast was a date or a datetime, we will serialize the date as
245245
// a string. This allows the developers to customize how dates are serialized
246246
// into an array without affecting how they are persisted into the storage.
247-
if ($attributes[$key] &&
248-
($value === 'date' || $value === 'datetime' ||
249-
$value === 'immutable_date' || $value === 'immutable_datetime')) {
247+
if ($attributes[$key] && in_array($value, ['date', 'datetime', 'immutable_date', 'immutable_datetime'])) {
250248
$attributes[$key] = $this->serializeDate($attributes[$key]);
251249
}
252250

0 commit comments

Comments
 (0)