Skip to content

Turatel OTP-Bulk SMS notification for Laravel

Notifications You must be signed in to change notification settings

macellan/turatel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turatel SMS Notifications Channel for Laravel

This package makes it easy to send sms notifications using Turatel with Laravel 10.0+

Contents

Installation

You can install this package via composer:

composer require macellan/turatel

Setting up the Turatel service

Add your Turatel sms gate configs to your config/services.php:

// config/services.php
...
    'sms' => [
        'turatel' => [
            'sms_service' => [
                'enable' => env('TURATEL_SMS_SERVICE_ENABLE', false),
                'debug' => env('TURATEL_SMS_SERVICE_DEBUG', false),
                'sandbox_mode' => env('TURATEL_SMS_SERVICE_SANDBOX_MODE', false),
                'base_url' => env('TURATEL_SMS_SERVICE_BASE_URL', 'https://processor.smsorigin.com/xml/process.aspx'),
                'platform_id' => env('TURATEL_SMS_SERVICE_PLATFORM_ID', 0),
                'channel_code' => env('TURATEL_SMS_SERVICE_CHANNEL_CODE', 0),
                'user_name' => env('TURATEL_SMS_SERVICE_USER_NAME', ''),
                'password' => env('TURATEL_SMS_SERVICE_PASSWORD', ''),
                'originator' => env('TURATEL_SMS_SERVICE_ORIGINATOR', ''),
            ],
        ],
    ],
...

Usage

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

use Illuminate\Notifications\Notification;
use Macellan\Turatel\Notifications\Messages\TuratelSmsMessage;

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

    public function toTuratelSms($notifiable): TuratelSmsMessage
    {
        return new TuratelSmsMessage('Test Message');
    }
}

In your notifiable model, make sure to include a routeNotificationForSms() method, which returns a phone number or an array of phone numbers.

public function routeNotificationForSms()
{
    return str_replace(['+', ' '], '', $this->phone);
}

On-Demand Notifications

Sometimes you may need to send a notification to someone who is not stored as a "user" of your application. Using the Notification::route method, you may specify ad-hoc notification routing information before sending the notification:

Notification::route('sms', '905554443322')  
            ->notify(new TestNotification());

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

About

Turatel OTP-Bulk SMS notification for Laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages