Skip to content
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

Add a note about the breaking change in getDates method when switching to Laravel 10 #8940

Closed

Conversation

mgralikowski
Copy link
Contributor

@mgralikowski mgralikowski commented Aug 4, 2023

Upgrade to Laravel 10 forced to move all attributes from $dates to $casts. It was a breaking change as we were struggling with a lot of errors related to forms.

It turned out that it was caused by the change in the getDates() method.

Example of usage of this method: https://github.com/LaravelCollective/html/blob/64ddfdcaeeb8d332bd98bef442bef81e39c3910b/src/Eloquent/FormAccessible.php#L31

Generally, I think the name of this method now is misleading a bit, as it is limited only to timestamps.
I am not the only one who noticed that -> laravel/framework#42587 (comment)

Add info about breaking change.
@taylorotwell
Copy link
Member

It still returns a list of "date" fields.

@mgralikowski
Copy link
Contributor Author

@taylorotwell, no. It doesn't as there is no more $dates attribute available.

Before the update, on average it returned me 3-6 dates (Carbon objects), after the upgrade it is limited to only 2 timestamps. I have an application with ~25 models where $dates was used, so after an update, I had a lot of Call to a member function format() on string errors and I spent 2 hours to find out what is the reason. I just wanted to save people time.

Sadly, in my case, there is easy no fix for this, as getDates is used by a third-party library. But in case using this method directly in-app code, thanks to this information, I would know, that I have to expect different results, and probably prepare my own method to "get dates" in a model, as you did not accept my PR.

@mgralikowski mgralikowski changed the title Update upgrade.md Add a note about the breaking change in getDates method when switching to Laravel 10 Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants