master

laravel/framework

Last updated at: 29/12/2023 09:20

SendEmailVerificationNotification.php

TLDR

This file contains the SendEmailVerificationNotification class, which handles the logic for sending email verification notifications to registered users.

Classes

SendEmailVerificationNotification

This class is responsible for handling the logic for sending email verification notifications to registered users. It listens for the Registered event and checks if the registered user needs to verify their email. If the user needs to verify their email and it has not been verified yet, the class calls the sendEmailVerificationNotification method on the user object.

<?php

namespace Illuminate\Auth\Listeners;

use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\Auth\MustVerifyEmail;

class SendEmailVerificationNotification
{
    /**
     * Handle the event.
     *
     * @param  \Illuminate\Auth\Events\Registered  $event
     * @return void
     */
    public function handle(Registered $event)
    {
        if ($event->user instanceof MustVerifyEmail && ! $event->user->hasVerifiedEmail()) {
            $event->user->sendEmailVerificationNotification();
        }
    }
}