MustVerifyEmail.php
TLDR
The provided file, MustVerifyEmail.php
, is a trait in the Illuminate\Auth
namespace. It contains methods related to email verification, including checking if the user's email is verified, marking the user's email as verified, sending the email verification notification, and getting the email address for verification.
Methods
hasVerifiedEmail
This method determines if the user has verified their email address by checking if the email_verified_at
attribute is not null.
markEmailAsVerified
This method marks the given user's email as verified by updating the email_verified_at
attribute with the current timestamp.
sendEmailVerificationNotification
This method sends the email verification notification to the user.
getEmailForVerification
This method returns the email address that should be used for verification.
<?php
namespace Illuminate\Auth;
use Illuminate\Auth\Notifications\VerifyEmail;
trait MustVerifyEmail
{
/**
* Determine if the user has verified their email address.
*
* @return bool
*/
public function hasVerifiedEmail()
{
return ! is_null($this->email_verified_at);
}
/**
* Mark the given user's email as verified.
*
* @return bool
*/
public function markEmailAsVerified()
{
return $this->forceFill([
'email_verified_at' => $this->freshTimestamp(),
])->save();
}
/**
* Send the email verification notification.
*
* @return void
*/
public function sendEmailVerificationNotification()
{
$this->notify(new VerifyEmail);
}
/**
* Get the email address that should be used for verification.
*
* @return string
*/
public function getEmailForVerification()
{
return $this->email;
}
}