gdpa / kavenegar
Kavenegar Notifications driver
Installs: 3 701
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.3|^8.0
- guzzlehttp/guzzle: ^7.0.1
- illuminate/notifications: ^8.0
- illuminate/support: ^8.0
Requires (Dev)
- mockery/mockery: ^1.3.1
- orchestra/testbench: ~6.0
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-08-21 00:06:51 UTC
README
This package makes it easy to sent Kavenegar Notifications with Laravel 5.3+.
Contents
Installation
You can install the package via composer:
composer require gdpa/kavenegar
Install for laravel 7:
composer require gdpa/kavenegar:^3.4
Install for laravel 6:
composer require gdpa/kavenegar:^2.0
Install for laravel < 5.8:
composer require gdpa/kavenegar:^1.0
Setting up the Kavenegar service
Add your Kavenegar REST API Key to your config/services.php
:
// config/services.php ... 'kavenegar' => [ 'api_key' => env('KAVENEGAR_API_KEY'), ], ...
Usage
There are two channels that you can use in your via()
method inside the notification:
KavenegarChannel
which represent simple send
api and KavenegarVerifyChannel
which provide verify lookup
api.
use NotificationChannels\Kavenegar\KavenegarChannel; use NotificationChannels\Kavenegar\KavenegarMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [KavenegarChannel::class]; } public function toKavenegar($notifiable) { return KavenegarMessage::create() ->sender("your-desired-sender-number") ->message('Hello world'); } }
use NotificationChannels\Kavenegar\KavenegarVerifyChannel; use NotificationChannels\Kavenegar\KavenegarMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [KavenegarVerifyChannel::class]; } public function toKavenegar($notifiable) { return KavenegarMessage::create() ->template("your-template-key(Refer to Kavenegar Docs)") ->type('sms') ->token('your default token on your verify message template') ->token('additional token data. For example token10', 10); } }
In order to let your Notification know which Kavenegar user you are targeting, add the routeNotificationForKavenegar
method to your Notifiable model.
This method needs to return an array containing the mobile number of your receptor.
public function routeNotificationForKavenegar() { return [ 'mobile_number' => 'receptor mobile number', ]; }
Available methods
sender('')
: Accepts a string value for setting sender number on kavenegar.message()
: Accepts a string value for setting your sms message.template()
: Accepts a string value for setting your sms template.type()
: Accepts a string value for setting your service type (sms, voice, ...).tokens()
: Accepts two string value for setting your tokens. Second string is optional and in case you don't provide it, it set your default token.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email morteza.poussaneh@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.