微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何在自定义模型上使用 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 举报,一经查实,本站将立刻删除。