laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
31.85k stars 10.79k forks source link

`toNexmo` notification method isn't firing #23150

Closed 1stevengrant closed 6 years ago

1stevengrant commented 6 years ago

Description:

I have a notification when a model is updated. The first task was to send the notification to Slack which works as expected.

public function toSlack($notifiable)
    {
//      Log::info($notifiable);

        return (new SlackMessage)
            ->success()
            ->from('Taxi Controller', ':taxi:')
            ->content(":wave: <!channel> : #" . $notifiable->id ." picked up by " . $notifiable->driver->name);
    }

Next I wanted to log the notifications to the database, this also works.

public function toArray($notifiable)
    {
        return [
            'driver_name' => $notifiable->driver->name,
            'date_accepted' => $notifiable->date_accepted,
            'address' => $notifiable->address,
            'mobile_phone' => $notifiable->mobile_phone,
        ];
    }

Then, we looked to hook into the Nexmo channel - but the toNexmo method doesn't seem to fire.

public function toNexmo($notifiable)
    {
        Log::info($notifiable);
    }

the via method has

public function via($notifiable)
    {
        return [
            'slack',
            'nexmo',
            'database'
        ];
    }

services.php has been updated and nexmo/client composer package installed.

'nexmo' => [
        'key' => env('NEXMO_KEY'),
        'secret' => env('NEXMO_SECRET'),
        'sms_from' => env('NEXMO_NUMBER'),
    ],

Steps To Reproduce:

1stevengrant commented 6 years ago

Turns out you actually need to fire a new Nexmo message and not just log.

Not ideal as I don't want to fire an SMS each time

AliN11 commented 5 years ago

Did you solve it? It's my problem too.