如何在自定义模型上使用 laravel MustVerifyEmail电子邮件验证

问题描述

好的,所以我有一个名为 SiteEmail 的模型。基本上我有一个名为 Site 的模型,它可以有多个与之关联的电子邮件,必须通过发送电子邮件进行验证。我想使用我在用户模型上使用的 laravel 附带的 laravel 电子邮件验证。我已经在 MustVerifyEmail 模型上实现了 SiteEmail 接口,并且它使用了 Notifiable 特性。电子邮件发送正常,但点击验证按钮时,显示签名无效。

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;
    }
}

我如何在此类模型上进行电子邮件验证?它在 User 模型上运行良好,但我认为这不是验证自定义模型的正确方法。任何帮助表示赞赏!谢谢!

PS:我认为这可能是因为生成的签名正在针对用户的电子邮件进行测试?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)