-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Datetime casting with custom format #2658
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have no idea why pipeline is failing. |
This reverts commit 764ceb1.
GromNaN
requested changes
Nov 2, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good start
hans-thomas
commented
Nov 2, 2023
GromNaN
approved these changes
Nov 2, 2023
GromNaN
reviewed
Nov 2, 2023
This comment was marked as outdated.
This comment was marked as outdated.
alcaeus
approved these changes
Nov 8, 2023
Thank you @hans-thomas |
@GromNaN Always a Pleasure❤️ |
3 tasks
GromNaN
added a commit
that referenced
this pull request
Mar 5, 2024
…ield with custom format (#2741) - Fix #2729 by removing the method `Model::castAttribute()` that was introduced by #2658 in 4.1.0. Tests added to ensure `null` is allowed in `date`, `datetime`, `immutable_date`, `immutable_datetime` and the variants with custom formats. - Change the behavior of `immutable_date:j.n.Y H:i` (with custom format), to reset the time. This behave differently than [Laravel 10.46 that treats it like a `immutable_datetime`](https://github.com/laravel/framework/blob/v10.46.0/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L866-L869).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi again,
As mentioned in the #2655 issue, casting date types with a custom format did not work properly. So I decided to cover all date types and fix this issue.
I tested these date types:
To achieve this goal, I override one of the cases in
castAttribute
method to handleimmutable_date
date type. Also, I overridetransformModelValue
method to check if the result is aDateTimeInterface
or not for applying defined custom formatting on the Carbon instance and resetting time in a customdate
type.In the end, I should say that all date values will be stored in DB as
Date
type. (not as an object or string anymore)