首页 文章

调用未定义的方法Illuminate \ Database \ Query \ Builder :: notify()

提问于
浏览
22

在Forgot Password中提交请求时 Laravel 5.3.6 中的问题 .

Error Details

调用未定义的方法Illuminate \ Database \ Query \ Builder :: notify()

Issue is in below file:

vendor \ laravel \ framework \ src \ Illuminate \ Auth \ Passwords \ PasswordBroker.php

Line 69. Code is below

$user->sendPasswordResetNotification(
    $this->tokens->create($user)
);

Function: sendResetLink

它在 Laravel 5.2 中运行良好,似乎无法在 5.3.6 版本中运行 . 你遇到过这个问题吗?

3 回答

  • 10

    您必须在 User 模型中添加 Illuminate\Notifications\Notifiable 特征 .

  • 8
    • 在用户模式下添加Notifiable trait .

    Illuminate\Notifications\Notifiable

    • 在你的app.php中添加:

    对于您的提供商:

    Illuminate\Notifications\NotificationServiceProvider::class,

    在别名中:

    'Notification' => Illuminate\Support\Facades\Notification::class,

    • 请记住在config / mail.php文件中更新您的设置 .
  • 53

    就我而言,在按照其他答案中给出的步骤后,我仍然会收到错误 .

    BadMethodCallException:调用未定义的方法Illuminate \ Database \ Query \ Builder :: notify()

    我失踪了

    使用须予公布

    ...
    use Illuminate\Notifications\Notifiable;
    class User extends Model
    {
         use SoftDeletes, Notifiable;
         ...
    

相关问题