Answer the question
In order to leave comments, you need to log in
Why does Call to undefined method routeNotificationFor() throw an error?
I make notifications.
So it's all right
public function sendNotification()
{
$user = User::find(1);
$details = [
'user_id' => Auth::id(),
'comment_id' => 4444,
];
Notification::send($user, new MyFirstNotification($details));
dd('done');
}
$user = User::find(1);
$user = Comment::find(1);
Call to undefined method App\Comment::routeNotificationFor()
Answer the question
In order to leave comments, you need to log in
See Alexey Sklyarov 's answer . Notifications in Laravel are designed to be sent to users, you cannot send them "globally" only if you literally send a separate notification to each user. In view of this, the User model by default uses the Notifiable trait, which inside contains the routeNotificationFor method, which is responsible for linking user data (phone number, email, database relays) and the notifications themselves.
Yes, the first argument is notifiable_id & notifiable_type. Actually, by default, this is always the user ID and the value from the morph map for the user model, or the namespace + user class name.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question