itpalert/web2sms-notification-channel

Web2sms Notification Channel for laravel.

1.0.0 2024-01-29 19:58 UTC

This package is auto-updated.

Last update: 2024-04-29 20:26:25 UTC


README

This package makes it easy to send notifications using web2sms with Laravel 10.0.

Contents

Installation

You can install the package via composer:

composer require itpalert/web2sms-notification-channel

Setting up the web2sms service

Add the following env variables to your .env:

// .env
...
WEB2SMS_KEY=8c78axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WEB2SMS_SECRET=e9a689cfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
...

Usage

Now you can use the channel in your via() method inside the notification:

use ITPalert\Web2smsChannel\Messages\Web2smsMessage;
use Illuminate\Notifications\Notification;

class ProjectCreated extends Notification
{
    public function via($notifiable)
    {
        return ['web2sms'];
    }

    public function toWeb2sms($notifiable)
    {
        return new Web2smsMessage('Content');
    }
}

In order to let your Notification know which phone number to use, add the routeNotificationForWeb2sms method to your Notifiable model.

This method needs to return a phone number.

public function routeNotificationForWeb2sms(Notification $notification)
{
    return $this->phone_number;
}

Available Message methods

  • content(string $content): Accepts a string value for the sms content.
  • from(string $from): Accepts a string value for the sender number.
  • unicode(): Set the message type.
  • clientReference(string $clientReference): Set the client reference (up to 40 characters).
  • statusCallback(string $callback): Set the webhook callback URL to update the message status.
  • schedule(string $schedule): Set the date the message should sent at.
  • visible(bool $visible): Set if the message should be visible at the web2sms dashboard.
  • usingClient(Client $client): Set the web2sms client instance.

Credits