This package makes it easy to send notifications using sms.ru with Laravel ^12.x.
Install this package with Composer:
composer require altrntv/sms-ruAdd 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'),
],
...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;
}| 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. |
Please see CHANGELOG for more information what has changed recently.
$ composer testIf you discover any security related issues, please email :author_email instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.