I have been reading about eloquent events. There is an event for every interaction with a Model: creating, created, updating, updated, saving, saved, deleting, deleted, restoring, restored.
I want to know the data from a Model when it has been updated and the data it has before. Is it possible? Because the documentation havent so much info about how to use these events.
You're looking for getDirty()
and getOriginal()
methods.
User::updating(function ($user) {
$dirty = $user->getDirty();
$original = $user->getOriginal();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With