简体   繁体   English

Laravel 使用变量更改重置密码电子邮件问候语

[英]Laravel change Reset Password email greeting with variable

I have an laravel 5.8 app, with the default auth installed.我有一个 Laravel 5.8 应用程序,安装了默认的身份验证。 I want to pass a variable to the password reset email template, so the greeting would look like "Hello, [username]".我想将一个变量传递给密码重置电子邮件模板,因此问候语看起来像“你好,[用户名]”。 The current email template looks like this:当前的电子邮件模板如下所示: 在此处输入图片说明

I didn't find where in the core files I can change this "Hello!"我没有在核心文件中找到可以更改此“您好!”的位置。 heading of the message消息的标题

EDIT: In my controller, I send the password reset like this(maybe the variable should be put somewhere on this line)编辑:在我的控制器中,我像这样发送密码重置(也许变量应该放在这条线上的某个地方)

$response = Password::sendResetLink($credentials, function (Message $message) {
            $message->subject($this->getEmailSubject());
        });

In a default Laravel app, the User model has a CanResetPassword interface with a sendPasswordResetNotification method.在默认的 Laravel 应用程序中,用户模型有一个带有sendPasswordResetNotification方法的CanResetPassword接口。 This method is created in a CanResetPassword trait that the user also uses.此方法是在用户也使用的CanResetPassword特征中创建的。

You could override this with your own method and create your own ResetPasswordNotification class.您可以使用自己的方法覆盖它并创建自己的ResetPasswordNotification类。 Try following it from the trait to that class.尝试从 trait 跟随它到那个类。

It does not look like it uses a view for the markup, so it shouldn't be too hard to do.它看起来不像是为标记使用视图,所以应该不会太难做到。 The ResetPassword class takes accepts a Notifiable , so you should have access to the name in there. ResetPassword类接受一个Notifiable ,因此您应该可以访问其中的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM