1

好的,所以我有一个名为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:我认为这可能是因为生成的签名正在针对用户的电子邮件进行测试?

4

0 回答 0