Search code examples
laravelnotificationssmsvonage

How to route Nexmo notification from different field Laravel?


I am trying to route my Nexmo notification in Laravel from a field other than phone_number which is what the docs state Nexmo looks for to use. I added this snippet of code from the Laravel docs:

public function routeNotificationForNexmo($notification)
{
    return $this->phone;
}

Because the field in my db is phone. But, when this is run, I get an error that says Type error: Too few arguments to function App\User::routeNotificationForNexmo(). What I don't understand is where I would pass through any data to this, and the Laravel docs don't state anymore about custom routing. So how do I route a Nexmo notification from a field other than phone_number?


Solution

  • Try remove the argument inside the routeNotificationForNexmo() function :

    public function routeNotificationForNexmo()
    {
        return $this->phone;
    }