On laravel 11 site creating new user I send sms using vonage service and
https://fajarwz.com/blog/send-sms-from-laravel-app-using-vonage/ plugin
I send notification as
$user->notify(new SendConfirmSmsToRegisteredUserNotification(user: $user, confirmCms: $confirmCms));
and Notification class :
<?php
namespace AppNotifications;
use AppModelsUser;
use IlluminateBusQueueable;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
use IlluminateNotificationsNotification;
use IlluminateNotificationsMessagesVonageMessage;
class SendConfirmSmsToRegisteredUserNotification extends Notification
{
use Queueable;
private string $siteName;
/**
* Create a new notification instance.
*/
public function __construct(private User $user, private string $confirmCms)
{
Log::info($confirmCms); // I SEE IN LOG FILE THIS MESSAGE
$this->siteName = 'Site name';
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['vonage'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return IlluminateNotificationsMessagesVonageMessage
*/
public function toVonage($notifiable): VonageMessage
{
Log::info($this->confirmCms); // I DO NOT SEE IN LOG FILE THIS MESSAGE
return (new VonageMessage)
->from($this->siteName)
->content('Confirm code ' .$this->confirmCms . '. Enter it!');
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
Method toVonage of thr class above is not even called. Not any errors in log file.
In .env file there are parameters VONAGE_KEY and VONAGE_SECRET.
I did not get any sms and in vonage dashdord in logs I did not find any records about my sms.
Is my Notification class invalid ? Or what can be the reason of the error ?
"laravel/framework": "^11.27.2",
"laravel/vonage-notification-channel": "^3.3"
Thanks in advance!