You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
If you have a specific default value for latitude and longitude, you can set them accordingly
$defaultLatitude = 0.0; // or any default value you prefer
$defaultLongitude = 0.0; // or any default value you prefer
$address = Address::updateOrCreate([
'code' => 'xxx'
], [
'latitude' => $defaultLatitude,
'longitude' => $defaultLongitude
]);
Maybe the author wanted the same behavior on creation vs update. In this case since the related PR was closed, the alternative is to make create method throws.
Laravel Version
11.10.0
PHP Version
8.2.14
Database Driver & Version
MySQL 8.0.36
Description
Cast decimal attribute fails if model already exist on database
Steps To Reproduce
Suppose we have a model Address like:
Work only if Model doesn't exist on Database:
Don't work:
The text was updated successfully, but these errors were encountered: