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

[10.x] Add timestamps casting and mutation support to Eloquent #47945

Closed
wants to merge 1 commit into from
Closed

[10.x] Add timestamps casting and mutation support to Eloquent #47945

wants to merge 1 commit into from

Conversation

amir9480
Copy link
Contributor

@amir9480 amir9480 commented Aug 3, 2023

This PR fixes #47769.

This PR adds a new method (freshTimestampForAttribute) to the Eloquent which can be used for creating fresh timestamp for any attribute considering either its mutation or casting and It's a replacement for the freshTimestampString method. so it will not ignore the casting or mutation of the model's attribute for any purpose.
This method can be used for other parts like SoftDeletes and touching related models instead of freshTimestampString.
For now I just used it to fix issue #47769.

Got the idea from @timacdonald PR (#47942).

@taylorotwell
Copy link
Member

Going to look at @timacdonald's PR. If this is different explain the alternatives.

@amir9480
Copy link
Contributor Author

amir9480 commented Aug 4, 2023

@taylorotwell
This PR supports other methods like upsert and touch for any attribute. created_at attribute is also supported and can add support for deleted_at in the future without limitations.

As @driesvints mentioned in the issue, freshTimestampString was the problem so I replaced it via another method.

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.

Cast on Updated At column not applied for rapid saves (i.e. unit tests)
2 participants