Skip to content

Unofficial Laravel notification channel Package for sms.ir

License

Notifications You must be signed in to change notification settings

hasanmonfared/smsir

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unofficial Laravel notification channel Package for sms.ir

Latest Version on Packagist Software License Build Status SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using Smsir with Laravel 5.5+, 6.x, 7.x , 8.x and 9.x

Contents

Installation

composer require rezahmady/smsir

Setting up the Smsir service

First add these environment variables in your .env file:

SMSIR_API_KEY="xxxx"
SMSIR_SECRET_KEY="xxxx"
SMSIR_LINE_NUMBER="xxxx"

then add this method to your User model

public function routeNotificationForSmsir()
{
    return $this->mobile;
}

Usage

sample notification class:

namespace App\Notifications\Sms;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Rezahmady\Smsir\SmsirChannel;
use Rezahmady\Smsir\SmsirMessage;

class VerificationCode extends Notification
{
    use Queueable;

    public $parameter;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($parameter)
    {
        $this->parameter = $parameter;
    }

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

    public function toSmsir($notifiable)
    {
        return (new SmsirMessage())
                ->setMethod('ultraFastSend')
                ->setTemplateId('47119')
                ->setParameters([
                    'VerificationCode' => $this->parameter
                ]);
        
    }

}

sample trigger this notification :

return auth()->user()->notify(new VerificationCode('1234'));

Available Message methods

A list of all available options

setMethod

is require

->setMethod('METHOD_NAME')

smsir has two method for send sms :

1. ultraFastSend require attributes is parameters (array) and templateId (string) set them with this chain methods :

->setTemplateId('THEMPLATE_ID')
->setParameters([...]);

2. sendVerificationCode

require attributes is code (string) set it with this chane method :

->setCode('YOUR_CODE')

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email ahmadireza15@gmail.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

Note: This package has been used to develop amirbagh75/smsir-php Thanks to Amirhossein Baghaie

About

Unofficial Laravel notification channel Package for sms.ir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%