Skip to content

altrntv/sms-ru

Repository files navigation

SmsRu notifications channel for Laravel

This package makes it easy to send notifications using sms.ru with Laravel ^12.x.

Contents

Installation

Install this package with Composer:

composer require altrntv/sms-ru

Setting up the SmsRu service

Add your SmsRu Api ID and Host to your config/services.php:

...
'smsru' => [
    'api_id'  => env('SMS_RU_API_ID'),
    'host' => env('SMS_RU_API_HOST'),
],
...

Usage

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

use Altrntv\SmsRu\SmsRuMessage;
use Altrntv\SmsRu\SmsRuChannel;
use Illuminate\Notifications\Notification;

class OrderStatus extends Notification
{
    public function via(mixed $notifiable): array
    {
        return [
            SmsRuChannel::class,
        ];
    }

    public function toSmsRu(mixed $notifiable): SmsRuMessage
    {
        return SmsRuMessage::create('Message');
    }
}

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

public function routeNotificationForSmsRu(): ?string
{
    return $this->phone;
}

Available Message methods

Method Description
to() Set a phone number
from(?string $from) Sender's name (must be agreed with the administration). If it is not filled in, your default sender will be specified as the sender.
ip(?string $ip) User's IP address
sendAt(?CarbonInterface $time) If you need a delayed dispatch, specify the time of dispatch. It is specified in UNIX TIME format (example: 1280307978). It must be no more than 2 months from the date of submitting the request. If the time is less than the current time, the message is sent immediately.
ttl(?int $ttl) The message lifetime is in minutes (from 1 to 1440).
daytime(bool $daytime = true) Takes into account the recipient's time zone.
translit(bool $translit = true) Translates all Russian characters into Latin.
test(bool $test = true) Simulates sending a message to test your programs for the correct processing of server responses. However, the message itself is not sent and the balance is not spent.
partnerId(?string $partnerId) If you participate in an affiliate program, specify this parameter in the request and receive a percentage of the cost of the sent messages. Your unique identifier is already specified in the parameter.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email :author_email 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.

About

Sms.ru Notifications Channel for Laravel

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages