Laravel模型事件 - 对特定列更新执行操作

as we all know Laravel has model events which are fired on certain instances, and we can perform actions on them, like created, creating, saved, saving, etc. What I want to know is that how can we know which column was updated on lets say 'saved' event like a user was updated and of course saving and saved events were fired, inside these events can one know which column was updated and perform actions accordingly ? Thanks in advance.

As @Joel Hinz said you can use getDirty() method.

getDirty() - get the attributes that have been changed since last sync

This method will return an array with names of changed columns:

public function boot()
{
    User::saving(function ($user) {
        $columns = $user->getDirty();

        foreach ($columns as $column => $newValue) {
            echo $column; // One of the changed columns.
        }
    });
}