Question: I am using an [Observer](https://laravel.com/docs/5.5/eloquent#observers) to watch if a user was updated.

Whenever a user is `updated` I would like to check if his `email` has been changed. 

Is something like this possible?

```
class UserObserver
{

    /**
     * Listen to the User created event.
     *
     * @param  \App\User  $user
     * @return void
     */
    public function updating(User $user)
    {
      // if($user->hasChangedEmailInThisUpdate()) ?
    }

}

```

Answer: 
Edit: Credits to <https://stackoverflow.com/a/54307753/2311074> for `getOriginal`

As `tadman` already said in the comments, the method `isDirty` does the trick:

```
class UserObserver
{

    /**
     * Listen to the User updating 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');
      }
    }

}

```

If you want to know the difference between `isDirty` and `wasChanged`, see <https://stackoverflow.com/a/49350664/2311074>
You don't have to get the user again from the database. The following should work:

```
public function updating(User $user)
{
  if($user->isDirty('email')){
    // email has changed
    $new_email = $user->email; 
    $old_email = $user->getOriginal('email'); 
  }
}

```