我在我的项目中使用php artisan make:auth,除了发送的重置密码链接外,一切都很完美.该链接未包含正确的URL,错过了项目名称.这是在我进入通知解决方案之前发送的链接: http:// localhost/password/reset/05929a8e465ddfa123a4c068da455cf63c3b9b90ec500a0e1045f092bbd0d97a 我在User类中创建了此方法:
public function sendPasswordResetNotification($token) {
$this->notify(new ResetPasswordNotification($token));
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个包含toMail方法的通知类来覆盖\ vendor\laravel\framework\src\Illuminate\Auth\Notifications\ResetPassword.php中的现有方法:
class ResetPasswordNotification extends Notification {
use Queueable;
...
...
public function toMail($notifiable) {
return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', route('password.reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
}
Run Code Online (Sandbox Code Playgroud)
我现在获得的链接按预期工作,这是发送的链接: http:// localhost/myproject/public/password/reset/435e453cfa30c968c96ded21c964d70e21459d6ae6ffae8f4972c229773e8a6a.但是,我不知道我是否直接在ResetPassword.php中更改了toMail方法,而不是通过通知进行操作会导致生产中的任何问题或其他问题,我只会更改 - >动作部分.
非常感谢.