LaravelPackages.net
Acme Inc.
Toggle sidebar
kafkiansky/laravel-sms-ru-channel

Laravel sms.ru channel

2
0
v1.0.0
About kafkiansky/laravel-sms-ru-channel

kafkiansky/laravel-sms-ru-channel is a Laravel package for laravel sms.ru channel. It currently has 0 GitHub stars and 2 downloads on Packagist (latest version v1.0.0). Install it with composer require kafkiansky/laravel-sms-ru-channel. Discover more Laravel packages by kafkiansky or browse all Laravel packages to compare alternatives.

Last updated

SmsRu notification channel for Laravel

test Software License Quality Score StyleCI Total Downloads Codecov

Content

Installation

Install package with Composer:

composer require kafkiansky/laravel-sms-ru-channel

Usage

Configuration

Register provider:

// config/app.php
'providers' => [
    ...
    Kafkiansky\SmsRuChannel\SmsRuProvider::class,
],

Add configuration in config/services.php:

// config/services.php

'sms_ru' => [
    'api_id' => env('SMS_RU_API_ID'),
    'login'  => env('SMS_RU_LOGIN', null),
    'password' => env('SMS_RU_PASSWORD', null),
    'partner_id' => env('SMS_RU_PARTNER', null),
    'test' => env('SMS_RU_TEST', 1),
    'json' => env('SMS_RU_JSON', 1),
    'from' => env('SMS_RU_FROM', null),
],

Read more about configuration on official site.

How to

First way

Create notification message:

use Illuminate\Notifications\Notification;
use Kafkiansky\SmsRu\Message\SmsRuMessage;
use Kafkiansky\SmsRu\Message\To;
use Kafkiansky\SmsRuChannel\SmsRuChannel;

final class RegistrationComplete extends Notification
{
    public function via($notifiable)
    {
        return [SmsRuChannel::class];
    }

    public function toSmsRu($notifiable)
    {
        return new SmsRuMessage(new To($notifiable->phone, 'Congratulations, you have become part of our application'));
    }
}

Second way

Or create routeNotificationForSmsRu method in notifiable instance:

use Illuminate\Notifications\Notifiable;

/**
 * @property string $phone
 */
class User
{
    use Notifiable;

    public function routeNotificationForSmsRu()
    {
        return $this->phone; // can be array of phone numbers
    }
}

In this case notification message should look like this:

use Illuminate\Notifications\Notification;
use Kafkiansky\SmsRuChannel\SmsRuChannel;

final class RegistrationComplete extends Notification
{
    public function via($notifiable)
    {
        return [SmsRuChannel::class];
    }

    public function toSmsRu($notifiable)
    {
        return 'Congratulations, you have become part of our application';
    }
}

Testing

$ composer test

License

The MIT License (MIT). See License File for more information.

Star History Chart