Laravel:密码重置针对用户的电子邮件检查

Laravel:密码重置针对用户的电子邮件检查

问题描述:

I have the following code to send the password reset email to the users email which is working:

$response = $this->passwords->sendResetLink($request->only('email'),function($message)
{
    $message->subject('Password Reminder');
});

What i want is that user should write their username instead of email, And i will check the email against that username , And will send the email.So i came up with this idea.

    $usernameToEmail = User::where('name','=', Input::get('username'))->first();  

    $response = $this->passwords->sendResetLink(['name' => $usernameToEmail],function($message)
    {
        $message->subject('Password Reminder');
    });

Which is not working also.

Am i missing something ?

You're close, but your $usernameToEmail variable contains a User object, not an email string. Most likely you just need to add a method to your chain:

$usernameToEmail = User::where('name','=', Input::get('username'))->first()->email;