itpalert / web2sms-notification-channel
Web2sms Notification Channel for laravel.
1.0.0
2024-01-29 19:58 UTC
Requires
- php: ^8.0
- illuminate/notifications: ^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
- itpalert/web2sms: ^1.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.2
- mockery/mockery: ^1.0
- orchestra/testbench: ^6.0|^7.0|^8.0|^9.0
README
This package makes it easy to send notifications using web2sms with Laravel 10.0.
Contents
Installation
You can install the package via composer:
composer require itpalert/web2sms-notification-channel
Setting up the web2sms service
Add the following env variables to your .env
:
// .env ... WEB2SMS_KEY=8c78axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WEB2SMS_SECRET=e9a689cfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
Usage
Now you can use the channel in your via()
method inside the notification:
use ITPalert\Web2smsChannel\Messages\Web2smsMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return ['web2sms']; } public function toWeb2sms($notifiable) { return new Web2smsMessage('Content'); } }
In order to let your Notification know which phone number to use, add the routeNotificationForWeb2sms
method to your Notifiable model.
This method needs to return a phone number.
public function routeNotificationForWeb2sms(Notification $notification) { return $this->phone_number; }
Available Message methods
content(string $content)
: Accepts a string value for the sms content.from(string $from)
: Accepts a string value for the sender number.unicode()
: Set the message type.clientReference(string $clientReference)
: Set the client reference (up to 40 characters).statusCallback(string $callback)
: Set the webhook callback URL to update the message status.schedule(string $schedule)
: Set the date the message should sent at.visible(bool $visible)
: Set if the message should be visible at the web2sms dashboard.usingClient(Client $client)
: Set the web2sms client instance.