📜  laravel 观察者获取旧值 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:17.453000             🧑  作者: Mango

代码示例2
User::updating(function($user)
{
    if ($user->username != $user->getOriginal('username')) {
        doSomething();
    }

    // If you need multiple attributes you may use:
    // $originalAttributes = $user->getOriginal();
    // $originalUsername = $originalAttributes['username']; 
});