shipper/laravel-winsms-channel

There is no license information available for the latest version (v1.1.4) of this package.

Laravel notification channel for WinSMS API

v1.1.4 2024-03-09 00:23 UTC

This package is auto-updated.

Last update: 2024-04-30 01:28:42 UTC


README

Latest Version on Packagist Total Downloads

A Laravel Notification Channel to send sms notification to your users in Tunisia using WinSMS. More details here https://www.winsms.tn.

Installation

You can install the package via composer:

composer require shipper/laravel-winsms-channel

You can publish configuration file using:

php  artisan vendor:publish --provider="Shipper\WinSMS\WinSMSServiceProvider"

Usage

First, you need to create have an active winsms account. Go to https://www.winsms.tn/ and create one. Once you have access to your account, you'll need to get your API KEY. These credentials will be used to communicate with Win SMS API. Go to https://winsmspro.com/sms/user/sms-api/info

Finally, add a new service in your config/service.php file.

// file: config/winsms.php

return [
    'api_key' => env('WINSMS_API_KEY', ''),
    'sender_id' => env('WINSMS_SENDER_ID', ''),
];

Configure your notification

In your notification class, add the WinSMS Channel in the via method and create a toWinSMS method.

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Shipper\WinSMS\WinSMSChannel;
use Shipper\WinSMS\WinSMSMessage;

class ConfirmationNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification's delivery channels.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [WinSMSChannel::class];
    }

    // ...others method here


     /**
     * Send sms using WinSMS API
     *
     * @param mixed $notifiable
     * @return array
     */
    public function toWinSMS($notifiable):WinSMSMessage
    {
        return (new WinSMSMessage())
            ->to($notifiable->phone_number)
            ->from('MyApp')
            ->content('Your account has been created successfully');
    }
}

Available Message methods

  • to (the receiver phone number)
  • from (the sender phone number)
  • content (the actual text message)

Using Facade

You can also use the facade to send sms notification.

use Shipper\WinSMS\Facades\WinSMS;

WinSMS::sendSMS('216XXXXXXXX', 'MyApp', 'Your account has been created successfully');

License

The MIT License (MIT). Please see License File for more information.