📌  相关文章
📜  laravel 检查字段是否已更改 - PHP 代码示例

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

代码示例3
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');
      }
    }

}