-
Notifications
You must be signed in to change notification settings - Fork 101
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
reason in updated() event #77
Comments
my hacky workaround is to set the |
I guess this has something to do that the old model is still loaded. You can try the following (untested): public function updated(Foo $foo)
{
$foo->refresh(); // Fresh data from the database
$version = $foo->currentVersion();
$action = $version->reason;
} Documentation: https://laravel.com/docs/8.x/eloquent#refreshing-models |
yeah .. totally makes sense .. and I tried that as well and again just now. but it doesn't get me the latest version. I also tried |
The problem in datetime, if we make changes very fast we got the same |
That's awesome, @benms. It'd be great if this solves the issue, and it'd make sense to use a timestamp that is not second-based to avoid this bug. |
I am using the
reason
inside anupdated
event. It seems likereason
is reset before this event is triggered, So I figured I just fetch it from the current version, but for some (likely stupid) reason, I sometimes then get the previous and not the current version. I assume there is some caching going on, so I wonder how I can reliably ensure I get the actual current version and not some cached instance that is no longer valid after the update?The text was updated successfully, but these errors were encountered: