我正在尝试在Laravel中自定义密码重置电子邮件 .
我必须覆盖此功能:
namespace Illuminate\Auth\Passwords;
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
use Illuminate\Http\Request;
trait CanResetPassword
{
/**
* Get the e-mail address where password reset links are sent.
*
* @return string
*/
public function getEmailForPasswordReset()
{
return $this->email;
}
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
这是我的尝试:
public function sendPasswordResetNotification($token, Requests $request)
{
Mail::to($request->email)->send(new newpassword($token));
}
我收到此错误:
Illuminate声明\ Foundation \ Auth \ User :: sendPasswordResetNotification($ token,Illuminate \ Http \ Request $ request)必须与Illuminate \ Contracts \ Auth \ CanResetPassword :: sendPasswordResetNotification($ token)兼容
2 回答
我很惊讶你要花那么长时间来定制电子邮件 .
试试这个:
然后在这里修改文件
适合我们的使用 .
现在,如果您需要更改副本并且您想要原始ResetPassword类使用的花哨按钮,则可以在User.php类中扩展邮件类,如下例所示 .
这是我们的副本,仅作为示例:
如果你读错了,它会告诉你你的 class 与
CanResetPassword
不兼容 . 如果你看那......您可以看到函数
sendPasswordResetNotification
应该只接受一个参数$token
. 因此,您需要从方法的签名中删除Request $request
作为参数 .要获取请求,您需要在
sendPasswordResetNotification
方法中使用函数request()
.