In Laravel the isDirty method can be used to examine the state of your model and its data to determine if changes have been made and need updating.
isDirty will determine if any of the model’s attributes have changed since it was loaded. The best part about it is you can check the whole model or specify attributes.
In the example below you can see that isDirty with no parameters will return true because the title got changed.
It will return true if we use the attributes as the parameter however it returns false for the other attributes that did not get changed.
$post->title = 'Example post title'; $post->isDirty();//true $post->isDirty('title');//true $post->isDirty('slug');//false $post->isDirty('created_at');//false
Note that isDirty can also accept multiple attributes:
$post->isDirty(['title', 'slug']);//true