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: 
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'); 
  }
}

```
A little late to the party, but might be helpful for future devs seeking a similar solution.

I recommend using the package **[Laravel Attribute Observer](https://github.com/alexstewartja/laravel-attribute-observer)**, as an alternative to polluting your Service Providers or filling your Observers with `isDirty()` and `wasChanged()` boilerplate.

So your use case would look like this:

```php
class UserObserver
{

    /**
     * Handle changes to the "email" field of User on "updating" events.
     *
     * @param  \App\User  $user
     * @param string $newValue The current value of the field
     * @param string $oldValue The previous value of the field
     * @return void
     */
    public function onEmailUpdating(User $user, string $newValue, string $oldValue)
    {
      // Your logic goes here...
    }

}

```

**[Laravel Attribute Observer](https://github.com/alexstewartja/laravel-attribute-observer)** is especially useful when you have a lot of attributes to observe on one or more models.

*Disclaimer: I am the author of **[Laravel Attribute Observer](https://github.com/alexstewartja/laravel-attribute-observer)**. If it saves you some development time, consider buying me a coffee.*