0

I'm trying to reuse the reset password in Laravel (Illuminate\Foundation\Auth\SendsPasswordResetEmails) to a form that I'm using.

Controller

public function resetPassword($id)
{
    $user = DB::table('users')->where('id', $id)->first();
    SendsPasswordResetEmails::sendResetLinkEmail($user->email);

    return back()->with('success', 'Password has been sent on email.');
}

The error I'm getting:

Non-static method Illuminate\Foundation\Auth\SendsPasswordResetEmails::sendResetLinkEmail() should not be called statically

1 Answer 1

1

As error showing, you should not call static way for sendResetLinkEmail function. You can use below code:

public function resetPassword($id)
{
        $user = DB::table('users')->where('id', $id)->first();
        $sendResetObject = new SendsPasswordResetEmails();
        $sendResetObject->sendResetLinkEmail($user->email);

        return back()->with('success', 'Password has been sent on email.');
}

Hope it helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

I've applied that but got this error Cannot instantiate trait Illuminate\Foundation\Auth\SendsPasswordResetEmails

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.