laravel check model column was changed

Solutions on MaxInterview for laravel check model column was changed by the best coders in the world

showing results for - "laravel check model column was changed"
Emil
15 Sep 2017
1class UserObserver
2{
3
4
5    /**
6     * Listen to the User created event.
7     *
8     * @param  \App\User  $user
9     * @return void
10     */
11    public function updating(User $user)
12    {
13      if($user->isDirty('email')){
14        // email has changed
15        $new_email = $user->email; 
16        $old_email = $user->getOriginal('email');
17      }
18    }
19
20}
21