user3235016
user3235016

Reputation: 317

Reuse reset password in Laravel API

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

Upvotes: 0

Views: 470

Answers (1)

Rohit Mittal
Rohit Mittal

Reputation: 2104

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.

Upvotes: 1

Related Questions