在Laravel 5.5中接收错误的重置密码链接

Rac*_*ati 3 php laravel laravel-5 laravel-5.4 laravel-5.5

我在我的项目中使用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方法,而不是通过通知进行操作会导致生产中的任何问题或其他问题,我只会更改 - >动作部分.

非常感谢.

pat*_*cus 16

在Laravel 5.5中,内置通知使用以下代码构建URL:

url(config('app.url').route('password.reset', $this->token, false)))
Run Code Online (Sandbox Code Playgroud)

config('app.url')可以通过APP_URL.env文件中设置变量来更改值.如果设置了该APP_URL值,则无需担心覆盖内置功能.

APP_URL=http://localhost/myproject/public
Run Code Online (Sandbox Code Playgroud)