【发布时间】:2016-09-25 15:12:00
【问题描述】:
我的情况是用户的唯一电子邮件可以有多个帐户。 意味着一封电子邮件与具有唯一用户名的多个帐户相关联。
我当前的代码适用于邮件,我想使用他们的用户名发送电子邮件,这意味着用户将输入他的用户名,然后与该用户名关联的电子邮件将获得密码重置链接
直接电子邮件的当前工作代码:
public function postEmail(Request $request)
{
$validator = Validator::make(Input::get(),
[
'email' => 'required|email'
]
);
if ($validator->fails()) {
return redirect()
->back()
->withErrors($validator->errors())
->with('message', 'Please fix your form fields.')
->with('form', 'recover')
->withInput(Input::except('password'));
}
$response = $this->passwords->sendResetLink($request->only('email'), function($message)
{
$message->subject('Password Reminder');
});
switch ($response)
{
case PasswordBroker::RESET_LINK_SENT:
return redirect()
->back()
->with('message', 'A verification email was sent to your email inbox.')
->with('form', 'recover')
->withInput(Input::except('password'));
case PasswordBroker::INVALID_USER:
dd('true');
}
}
我添加了以下行:
$usernameToEmail = App\User::where('name','=', Input::get());
然后我将$usernameToEmail->email 传递给
$response = $this->passwords->sendResetLink($usernameToEmail->email,
function($message)
{
$message->subject('Password Reminder');
});
这会引发以下错误:
Type error: Argument 1 passed to Illuminate\Auth\Passwords\PasswordBroker::sendResetLink() must be of the type array, string given
【问题讨论】:
标签: php laravel laravel-5.2