使用Laravel 5,我需要2个不同的密码重置电子邮件视图 . 电子邮件视图的默认路径为 emails.password . 但在某些情况下,我想发送 emails.password_alternative .
我怎样才能做到这一点? (来自Laravel的PasswordBroker)
这是我目前的代码:
public function __construct(Guard $auth, PasswordBroker $passwords)
{
$this->auth = $auth;
$this->passwords = $passwords;
}
public function sendReset(PasswordResetRequest $request)
{
//HERE : If something, use another email view instead of the default one from the config file
$response = $this->passwords->sendResetLink($request->only('email'), function($m)
{
$m->subject($this->getEmailSubject());
});
}
2 回答
使用PasswordBroker并基于Illuminate/Auth/Passwords/PasswordBroker.php类,
$emailView
是受保护的变量,因此在实例化类后,您无法更改该值 .但是,您有几个解决方案:
这是一个更丑陋的解决方案,如果你有自动化测试,这将是一个痛苦的工作 .
免责声明:我没有测试过任何此类代码 .
对于对Laravel 5.2感兴趣的任何人,您可以通过添加设置自定义html和文本电子邮件视图以重置密码
在中间件调用之前,在构造函数中的PasswordController.php .
这将覆盖PasswordBroker的app / config / auth.php设置 .
密码重置电子邮件的刀片模板位于:
花了我很长时间 .
积分:http://ericlbarnes.com/2015/10/14/how-to-send-both-html-and-plain-text-password-reset-emails-in-laravel-5-1/ http://academe.co.uk/2014/01/laravel-multipart-registration-and-reminder-emails/