2 years ago

Undefined Method routeNotificationFor while saving notification to database

Posted 2 years ago by Naumanz

I am trying to save a notification in database with Laravel 5.4. And It gives

BadMethodCallException in Builder.php line 2443: Call to undefined method Illuminate\Database\Query\Builder::routeNotificationFor()

While below is my Notification class. What could be the possible problem ?


namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notifiable;

class NewUserAdded extends Notification
    use Queueable;
    private $user;
     * Create a new notification instance.
     * @return void
    public function __construct($user)
        $this->user = $user;

    public function via($notifiable)
        return ['database'];

    public function toDatabase($notifiable)
         return [
            'message' => 'A new user with id '. $this->user->user_id . 'has been added to the system',

Please sign in or create an account to participate in this conversation.