douguan8940 2019-04-25 05:33
浏览 330

方法Illuminate \ Database \ Query \ Builder :: routeNotificationFor不存在

I faced issue in Laravel 5.7

Error as follows

Method Illuminate\Database\Query\Builder::routeNotificationFor does not exist.

My code as follows

$users = User::find(1);
Notification::send($users, new UserActivity());

Users return value as follows

{"id":1, "name":"First Name", "email":"name@example.com","mobile":"9999999999","reset_password":0,"avatar":null,"created_at":"2019-04-11 10:39:08","updated_at":"2019-04-11 10:39:08","deleted_at":null}

This is working fine with Auth user as follows

Notification::send(Auth()->user(), new UserActivity());

If anyone faced the same issue ?

  • 写回答

1条回答 默认 最新

  • dongyue7796 2019-04-25 07:07
    关注

    Problem solved from the hint @nakov

    Have to add Illuminate\Notifications\Notifiable trait in User model.

    评论

报告相同问题?