undjike / ekosms-laravel-notification-channel
Laravel Notification Channel based on EkoSMS service
v1.0.1
2021-11-13 10:05 UTC
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^6.2 || ^7.0 || ^7.3
- illuminate/notifications: ~6.0 || ~7.0 || ~8.0
- illuminate/support: ~6.0 || ~7.0 || ~8.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.0 || ^9.0
README
Introduction
This is a package for Laravel Applications which enables you to send notifications through EkoSMS Channel.
The package uses EkoSms Service to perform SMS dispatching.
Installation
This package can be installed via composer. Just type :
composer require undjike/ekosms-laravel-notification-channel
Usage
After installation, configure your services in congig/services.php
by adding :
<?php return [ //... 'ekosms' => [ 'username' => env('EKOSMS_USERNAME'), // You can type in directly your credentials 'password' => env('EKOSMS_PASSWORD') ], ];
Once this is done, you can create your notification as usual.
<?php namespace App\Notifications; use Illuminate\Notifications\Notification; use Undjike\EkoSmsNotificationChannel\EkoSmsChannel; use Undjike\EkoSmsNotificationChannel\EkoSmsMessage; class EkoSmsNotification extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [EkoSmsChannel::class]; // or return 'ekosms'; } /** * @param $notifiable * @return mixed */ public function toEkoSms($notifiable) { return EkoSmsMessage::create() ->body('Type here you message content...') ->sender('Brand name'); // or return 'Type here you message content...'; } }
To get this stuff completely working, you need to add this to your notifiable model.
/** * Attribute to use when addressing EkoSMS notification * * @returns string|array */ public function routeNotificationForEkoSms() { return $this->phone_number; // Can be a string or an array of valid phone numbers }
Enjoy !!!
License
The MIT License (MIT). Please see License File for more information.