Skip to content

Commit

Permalink
Swap multiple logical OR for in_array when checking date casting (#38307
Browse files Browse the repository at this point in the history
)
  • Loading branch information
michaeldyrynda authored Aug 10, 2021
1 parent ec405fc commit 54713b3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt
// If the attribute cast was a date or a datetime, we will serialize the date as
// a string. This allows the developers to customize how dates are serialized
// into an array without affecting how they are persisted into the storage.
if ($attributes[$key] &&
($value === 'date' || $value === 'datetime' ||
$value === 'immutable_date' || $value === 'immutable_datetime')) {
if ($attributes[$key] && in_array($value, ['date', 'datetime', 'immutable_date', 'immutable_datetime'])) {
$attributes[$key] = $this->serializeDate($attributes[$key]);
}

Expand Down

0 comments on commit 54713b3

Please sign in to comment.