-
Notifications
You must be signed in to change notification settings - Fork 399
Date always stored even if none changed #1024
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
Comments
Hi, could you upload a repo with just the source code for showing this problem? Or a failing test showing it? |
Hi i tested some more. I always use Carbon for dates and stuf because of the casts. But when i give the new date a Carbon formatted as Y-m-d. then it isnt triggered. If i had the spare time to take a look at this i would have and i would have posted a PR. |
sounds feasible, try a PR |
unfortunaly i dont have the time for it, atm I have fixed it atm using mutators. I hope someone can take a look at this ;-) |
#483 since 2019, I doubt it |
I could only replicate this issue if I was applying the same value repeatedly in the same request, i.e. setting That said, Laravel probably shouldn't be identifying the value as dirty if it knows the effective part of the value hasn't actually changed. Both Are you able to share whatever part of your code is triggering it to see if there is another way around it? |
Hi, I am not able to share any code as it is proprietery. I have currently fixed it using a setter public function startDate(): Attribute
{
return Attribute::make(
set: static fn ($value) => isset($value) ? \Illuminate\Support\Carbon::parse($value)?->toDateString() : $value,
);
} |
PHP Version
8.3
Laravel Version
12.0
Package Version
Latest release
Description
A issue that has been reported before but no solution given: #483
I have the same issue where i have my database correctly set-up. The attribute is correctly being casted as 'datetime:Y-m-d' The save action has the same date as previous saved so the data after save was not dirty. But the audit is being logged as seen in below screenshot
This in my opinion is a core issue. Audits should only be saved if a database record was indeed different than before. Or at least respect the casts instead of the 'carbon' value being recorded as new value, which isnt even possible to save in the database.
Please give this a proper look or give us the proper way to handle this so the database isnt being filled with unneeded data.
Steps To Reproduce
.
Possible Solutions
No response
The text was updated successfully, but these errors were encountered: