[英]Reuse reset password in Laravel API
我正在嘗試將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()不應靜態調用
如錯誤所示,您不應為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.');
}
希望對您有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.