Skip to content

Fix casting issues (issue: #2703) #2705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 16, 2024
Prev Previous commit
Next Next commit
Cleanup casting in Model::setAttribute
Co-authored-by: Jérôme Tamarelle <jerome@tamarelle.net>
  • Loading branch information
stubbo and GromNaN authored Jan 10, 2024
commit 2a9d836cb712ace34b3d8731610341da4ec8458f
6 changes: 3 additions & 3 deletions src/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ public function setAttribute($key, $value)
$castOptions = Str::after($casts[$key], ':');

// Can add more native mongo type casts here.
$value = match (true) {
$castType === 'decimal' => $this->fromDecimal($value, $castOptions),
default => $value,
$value = match ($castType) {
'decimal' => $this->fromDecimal($value, $castOptions),
default => $value,
};
}

Expand Down