PushSMS notifications channel for Laravel
batyukovstudio/laravel-notification-channels-pushsms-ru is a Laravel package for pushsms notifications channel for laravel.
It currently has 0 GitHub stars and 292 downloads on Packagist (latest version v12.0.3).
Install it with composer require batyukovstudio/laravel-notification-channels-pushsms-ru.
Discover more Laravel packages by batyukovstudio
or browse all Laravel packages to compare alternatives.
Last updated
This package makes it easy to send notifications using pushsms.ru with Laravel.
Install this package with Composer:
composer require batyukovstudio/laravel-notification-channels-pushsms-ru
The service provider gets loaded automatically. Or you can do this manually:
// config/app.php
'providers' => [
...
NotificationChannels\PushSMS\PushSmsServiceProvider::class,
],
Add your PushSms token to your .env:
// .env
...
PUSHSMS_TOKEN=qwerty123
You need to replace Notification extend with PushSmsNotification class.
namespace App\Notifications;
use NotificationChannels\PushSMS\Notifications\PushSmsNotification;
class MyNotification extends PushSmsNotification
{
use Queueable;
// ...
}
PushSmsNotification contains $content variable for your text message and toPushSms method. This method will receive a $notifiable entity and should return an NotificationChannels\PushSMS\ApiActions\PushSmsMessage instance:
// PushSmsNotification
}
use Illuminate\Notifications\Notification;
use NotificationChannels\PushSMS\ApiActions\PushSmsMessage;
use NotificationChannels\PushSMS\Notifications\Interfaces\PushSmsable;
abstract class PushSmsNotification extends Notification implements PushSmsable
{
protected string $content;
public function toPushSms($notifiable): PushSmsMessage
{
return PushSmsMessage::create()->content($this->content);
}
}
You can use the channel in your via() method inside the notification:
namespace App\Notifications;
use NotificationChannels\PushSMS\Notifications\PushSmsNotification;
use NotificationChannels\PushSMS\PushSmsChannel;
class MyNotification extends PushSmsNotification
{
public function via($notifiable)
{
return [PushSmsChannel::class];
}
}
In your notifiable model, make sure to include a routeNotificationForPushsms() method, which returns a phone number
or an array of phone numbers.
public function routeNotificationForPushsms()
{
return $this->phone;
}
content(): Set a content of the notification message.