boot function not fired in laravel model


I want to make email_verified_at null and send confirmation email if user updated their email. And after reading some tutorial on Internet I found something called boot function. But somehow my boot function in my User model is not fired.

Model User.php

class User extends Authenticatable implements MustVerifyEmail
    use Notifiable;

    protected static function boot()

        static::updating(function (User $user) {
            if (in_array('email', $user->getChanges())) {
                $user->email_verified_at = null;

And this is the controller for updating profile

 public function update_profile(Request $request)
        try {
            $profile = User::where('id', Auth::user()->id)->first();
            $profile->name = $request->name;
            $profile->email = $request->email;
            $profile->phone = $request->phone;
            $profile->gender = $request->gender;
            $profile->birthday = $request->birthday;


Source: Laravel

Categorised as eloquent, laravel Tagged ,


Leave a Reply

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us