Ok so i have a model named SiteEmail
. Basically i have a model named Site and it can have multiple emails associated with it, which has to be verified by sending an email. I want to use the laravel email verification that ships with laravel which i have used on the user model. I have implemented the MustVerifyEmail
interface on the SiteEmail
model and it is using the Notifiable
trait. The emails are being sent fine, but on clicking on the verify button, it says invalid signature.
class SiteEmail extends Model implements MustVerifyEmail
{
use Notifiable;
protected $fillable = ['site_id', 'user_id', 'email', 'email_verified_at'];
/**
* Determine if the user has verified their email address.
*
* @return bool
*/
public function hasVerifiedEmail()
{
return $this->email_verified_at != null;
}
/**
* Mark the given user's email as verified.
*
* @return bool
*/
public function markEmailAsVerified()
{
$this->update([
'email_verified_at' => now(),
]);
}
/**
* 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;
}
}
How do i approach email verification on such models? It works fine on the User
model, but i don't think this is the correct way to verify custom models. Any help is appreciated! Thanks!
PS: I think this might be happening because the signature generated is being tested against the user's email?