powertic / utalk-notification-channel
Utalk Laravel Notifications Channel
Requires
- php: ^7.2.5 || ^8.0
- guzzlehttp/guzzle: ^6.2 || ^7.0
- illuminate/notifications: ^6.0 || ^7.0 || ^8.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0
- propaganistas/laravel-phone: ^4.2
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^4.0 || ^5.0 || ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-25 21:48:46 UTC
README
This package makes it easy to send Utalk messages using the Laravel notification system. Supports 5.5+, 6.x, 7.x and 8.x.
Contents
Installation
You can install the package via composer:
composer require powertic/utalk-notification-channel
Setup
Add your Utalk token on app/services.php
file. You can get your API Token here.
... 'utalk' => [ 'token' => env('UTALK_TOKEN'), ],
You need to create a UTALK_TOKEN
on your .env
file.
Usage
Now you can use the channel in your via()
method inside the notification:
use Powertic\Utalk\UtalkChannel; use Powertic\Utalk\UtalkMessage; use Illuminate\Notifications\Notification; class TeamCreated extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [UtalkChannel::class]; } /** * Get the UTalk representation of the notification. * * @param mixed $notifiable * @return \Powertic\Utalk\UtalkMessage */ public function toUtalk($notifiable) { return UtalkMessage::create() ->message("Hello World!"); } }
In order to let your Notification know which number should receive the message, add the routeNotificationForUtalk
method to your Notifiable model.
This method expects a valid E.164 mobile number where the notification will be sent.
/** * Route notifications for the Utalk channel. * * @return string */ public function routeNotificationForUtalk() { return $this->mobile; }
Available methods
message('Hello World!')
: Accepts a string as message to send.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email luizeof@gmail.com 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.