composer require tnmdev/sms-notifation-channel
namespace TNM\SMSNotification\Notifications;
use Illuminate\Notifications\Notification;
use TNM\SMSNotification\Channels\SMSChannel;
class SMSNotification extends Notification
{
private string $message;
public function __construct(string $message)
{
$this->message = $message;
}
public function via($notifiable)
{
return [SMSChannel::class];
}
public function toSMS($notifiable): string
{
return $this->message;
}
}
use TNM\SMSNotification\Notifications\SMSNotification;
Notification::send($user, new SMSNotification('This is a sample notification'));
The following command will publish a config file config/sms_notification.php
php artisan vendor:publish --provider="TNM\SMSNotification\ChannelServiceProvider" --tag="config"
You can change the messenger URL either by editing the config directly or by adding an .env
entry
SMS_NOTIFICATION_MESSENGER_URL="https://your-messanger-api"
'messenger_url' => env('SMS_NOTIFICATION_MESSENGER_URL', 'http://localohost'),
By default, we look for the phone_number
attribute on the notifiable entity. If your application has a different
attribute, change that in the config
'notifiable_attribute' => 'msisdn'