Ad

Upgrading Laravel 4 Password Reset Controller To Laravel 5

- 1 answer

I have successfully upgraded most of my Laravel 4 application to Laravel 5, but the password reset portion is giving me a hard time. When I try to send the password reset email, I get this error:

ErrorException in PasswordBrokerManager.php line 137: call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Auth\Passwords\PasswordBroker' does not have a method 'remind'

This is the code it doesn't like:

/**
 * Handle a POST request to remind a user of their password.
 *
 * @return Response
 */
public function postRemind()
{
    switch ($response = Password::remind(Input::only('email')))
    {
        case Password::INVALID_USER:
            return Redirect::back()->with('error', Lang::get($response));

        case Password::REMINDER_SENT:
            return view('notifications.email');
    }
}

Any ideas why this might not be working?

EDIT

Changed Password::remind to Password::sendResetLink, and now I am getting this error:

FatalErrorException in EloquentUserProvider.php line 126: Class '\App\User' not found

It is correct, I do not have a class in the \App namespace since I moved it into \App\Models. How can I let it know that it should be looking for \App\Models\User instead?

Ad

Answer

You need to change the user model's fully qualified class name in the config/auth.php file, in the providers configuration values:

...
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],
    ...
]
...

Aside from that, Laravel 5 already has a App\Http\Controllers\Auth\PasswordController class that imports the Illuminate\Foundation\Auth\ResetsPasswords trait which handles all that forgot password functionality.

Ad
source: stackoverflow.com
Ad