laravel 5.4 密码重置问题——发送邮件
Posted
技术标签:
【中文标题】laravel 5.4 密码重置问题——发送邮件【英文标题】:Problems with laravel 5.4 password resets – sending e-mail 【发布时间】:2017-08-31 15:21:10 【问题描述】:laravel 5.4 密码重置问题 - 发送电子邮件
经过几个小时的研究,我不知道如何修复这个相当标准的 laravel 5.4 实现。我添加了一个多重身份验证系统,但我认为这不会对正在执行的代码产生影响。我正在运行邮寄路线来发送电子邮件……但在那之后我迷失了追踪代码的过程。下面,请找到生成的错误以及其他相关代码。我不确定错误是否在用户模型中,但肯定有。感谢您的帮助‼!
BadMethodCallException in Builder.php line 2443:Call to undefined method Illuminate\Database\Query\Builder::notify()
1. in Builder.php line 2443
2. at Builder->__call('notify', array(object(ResetPassword))) in Builder.php line 1245
3. at Builder->__call('notify', array(object(ResetPassword))) in Model.php line 1329
4. at Model->__call('notify', array(object(ResetPassword))) in CanResetPassword.php line 27
5. at User->sendPasswordResetNotification('c85443ddc950e30338975234e3ffcd10409efc8c43741e368b3f066398734fd5') in PasswordBroker.php line 70
6. at PasswordBroker->sendResetLink(array('email' => xxx@yahoo.com')) in SendsPasswordResetEmails.php line 33
7. at ForgotPasswordController->sendResetLinkEmail(object(Request))
8. at call_user_func_array(array(object(ForgotPasswordController), 'sendResetLinkEmail'), array('request' => object(Request))) in Controller.php line 55
9. at Controller->callAction('sendResetLinkEmail', array('request' => object(Request))) in ControllerDispatcher.php line 44
10. at ControllerDispatcher->dispatch(object(Route), object(ForgotPasswordController), 'sendResetLinkEmail') in Route.php line 203
11. at Route->runController() in Route.php line 160
12. at Route->run() in Router.php line 559
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use App\User;
class ForgotPasswordController extends Controller
use SendsPasswordResetEmails;
public function __construct() $this->middleware('guest');
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\CanResetPassword; // DOES THIS NEED TO BE REFERENCED SOMEPLACE ELSE?
class User extends Authenticatable
use Notifiable;
【问题讨论】:
【参考方案1】:我能够回答我自己的问题。那么下面的链接没有产生同样的错误,结果是一样的。我创建了另一个控制器并调用了在忘记密码控制器中调用的相同过程,一切都可以无缝运行。
Laravel 5.4 Password Reset
use App\user;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class guestController extends Controller
public function __construct() $this->middleware('guest');
use SendsPasswordResetEmails;
public function sendPasswordEmail(request $request)
$a=user::where('email',Request('email'))->first();
if(count($a)>0)
$this->sendResetLinkEmail($request);
return redirect('password/emailThankyou');
else
return redirect()->back();
【讨论】:
以上是关于laravel 5.4 密码重置问题——发送邮件的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 laravel 5 中的队列通过电子邮件发送密码重置链接