Skip to content

tnmdevs/sms-notification-channel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel SMS Notification Channel

Quick Start

Install the package

composer require tnmdev/sms-notifation-channel

Sample implementation

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;
    }
}

Using the notification

use TNM\SMSNotification\Notifications\SMSNotification;

Notification::send($user, new SMSNotification('This is a sample notification'));

Configuration

Publishing the config

The following command will publish a config file config/sms_notification.php

php artisan vendor:publish --provider="TNM\SMSNotification\ChannelServiceProvider" --tag="config"

Messenger URL

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'),

Notifiable Attribute

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'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages