在 Laravel 忘记密码模板电子邮件 link 中的令牌旁边添加电子邮件

Add email next to token in Laravel forgot password template email link

我正在使用 Laravel 8.5 身份验证系统。当用户想要更改密码时,它会发送一封带有 link 的电子邮件。默认电子邮件包含 link,如下所示:

http://mywebsite/api/forgot-password?token=2ccece360b031db4dcadea0cbdf8dd47a1712632b727487a7226f19f8f607cc7&email=MyEmail%40gmail.com

我对电子邮件模板做了一些更改。在 ResetPasswordNotification.php 我添加了这个:

public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->subject('MyApp password reset')
                    ->line('You are receiving this email because we received a password reset request for your account.')
                    ->action('Reset Password', $this->url)
                    ->line('This password reset link will expire in 60 minutes.')                    
                    ->line('If you did not request a password reset, no further action is required.');
    }

User.php 我有:

public function sendPasswordResetNotification($token)
    {    
        $url = 'http://mywebsite/en/change-password?token=' . $token;    
        $this->notify(new ResetPasswordNotification($url));
    }

现在我收到这个 link:

http://mywebsite/en/change-password?token=8f87fc2d504507as385b4c47cb015cee4192749d3f1d641863524d513abb2a39

只包含令牌,不包含电子邮件。如何向其中添加电子邮件,使其看起来像这样:

http://mywebsite/en/change-password?token=8f87fc2d504507as385b4c47cb015cee4192749d3f1d641863524d513abb2a39&email=UserEmail@gmail.com

尝试将电子邮件传递给 url。

public function sendPasswordResetNotification($token)
{    
    $url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' .$this->email;    
    $this->notify(new ResetPasswordNotification($url));
}

只需在 $token 旁边添加 $this->email

public function sendPasswordResetNotification($token)
{    
    $url = 'http://mywebsite/en/change-password?token=' . $token . '&email=' . $this->email;    
    $this->notify(new ResetPasswordNotification($url));
}