guizo

Observer column update isDirty or wasChanged

Posted 8 months ago by guizo

I'm using a observer to do some things when a specific column from the model is updated.

To do so I used the method isDirt() and it worked. But I saw in the documentation the method wasChanged with the same description, parameters and return value. The name wasChanged makes much more sense for me but unfortunately does not work as expected. The difference between isDirty and wasChanged is that the first calls getDirty() and the latter getChanges().

Examining the code I can't understand when wasChanged could be used. Just curious.

Here are the methods: https://laravel.com/api/master/Illuminate/Database/Eloquent/Model.html

Please sign in or create an account to participate in this conversation.