【问题标题】:Laravel - sendResetLink not workingLaravel - sendResetLink 不起作用
【发布时间】:2016-08-09 09:48:25
【问题描述】:

在我的项目中,我已授予管理员角色将用户添加到站点的权限。出于安全原因,我散列一个随机字符串,作为临时密码存储,然后我想向用户发送一封带有标准 Laravel 重置密码模板的电子邮件。

我有以下几点:

$user = new User();
$user->name = Input::get('name');
$user->email = Input::get('email');
$user->password = Hash::make(str_random(8));
$user->save();

$response = Password::sendResetLink(Input::get('email'), function (Message $message) {
        $message->subject('Password Reset');
    }); 

我得到的错误是

参数 1 传递给 Illuminate\Auth\Passwords\PasswordBroker::sendResetLink() 必须是 类型数组,给定字符串

如何在 Laravel 中触发此功能,以便向用户发送密码重置电子邮件?谢谢。

【问题讨论】:

  • 我认为这个错误是不言自明的。 sendResetLink 需要一个数组,而您提供的是一个字符串。
  • @PawelMysior,非常正确,这就是我遇到的问题。我不确定它在数组中想要什么。

标签: php laravel laravel-5.2 forgot-password


【解决方案1】:

这里的问题是你正在发送字符串电子邮件,你应该发送数组(这就是错误所说的)。

在这种情况下,您应该使用:

Request::only('email')

而不是

Input::get('email')

【讨论】:

  • 感谢您的回复。我试过了,但返回以下错误Non-static method Illuminate\Http\Request::only() should not be called statically, assuming $this from incompatible context
  • @Ben 所以在这里将Request 更改为\Request 以在此处使用Request 外观。
猜你喜欢
  • 2019-09-18
  • 2018-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-23
  • 2018-10-18
  • 2017-06-18
相关资源
最近更新 更多