【问题标题】:Reuse reset password in Laravel API在 Laravel API 中重用重置密码
【发布时间】:2019-03-31 12:54:49
【问题描述】:

我正在尝试将 Laravel (Illuminate\Foundation\Auth\SendsPasswordResetEmails) 中的重置密码重用到我正在使用的表单中。

控制器

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.');
}

我得到的错误:

非静态方法 Illuminate\Foundation\Auth\SendsPasswordResetEmails::sendResetLinkEmail() 不应该静态调用

【问题讨论】:

    标签: php laravel-5.7


    【解决方案1】:

    如错误所示,您不应该为sendResetLinkEmail 函数调用静态方式。您可以使用以下代码:

    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.');
    }
    

    希望对你有帮助。

    【讨论】:

    • 我已经应用了,但是得到了这个错误Cannot instantiate trait Illuminate\Foundation\Auth\SendsPasswordResetEmails
    猜你喜欢
    • 2019-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 2017-08-04
    • 2020-10-01
    • 1970-01-01
    相关资源
    最近更新 更多