📜  laravel 检查模型列已更改 - PHP 代码示例

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

代码示例1
class UserObserver
{


    /**
     * Listen to the User created event.
     *
     * @param  \App\User  $user
     * @return void
     */
    public function updating(User $user)
    {
      if($user->isDirty('email')){
        // email has changed
        $new_email = $user->email; 
        $old_email = $user->getOriginal('email');
      }
    }

}