hebinet / laravel-websms-notification-channel
WebSMS Notification Channel for laravel.
v1.5.0
2024-12-01 08:17 UTC
Requires
- php: ^8.0
- hebinet/websms-client: ^2.0
- illuminate/notifications: ^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- mockery/mockery: ^1.0
- pestphp/pest: ^1.21
- phpunit/phpunit: ^9.5
README
Provides a Notification Channel for WebSms
Installation
You can install it using Composer:
composer require hebinet/laravel-websms-notification-channel
Then publish the config file of the package.
php artisan vendor:publish --provider="Hebinet\Notifications\WebSmsChannelServiceProvider" --tag=config
Usage
If a notification supports being sent as an SMS, you should define a toWebsms
method on the notification class.
This method will receive a $notifiable
entity and should return a string
with the content of the SMS:
/** * Get the WebSMS / SMS representation of the notification. * * @param mixed $notifiable * @return string */ public function toWebsms($notifiable) { return 'Your SMS message content'; }
Routing SMS Notifications
To route Nexmo notifications to the proper phone number,
define a routeNotificationForWebsms
method on your notifiable entity:
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * Route notifications for the WebSms channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ public function routeNotificationForWebsms($notification) { return $this->phone_number; } }
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email office@hebinet.at instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.