|
1 | | -# smspoh |
2 | | -Smspoh Notifications Channel for Laravel |
| 1 | +# Smspoh Notifications Channel for Laravel |
| 2 | + |
| 3 | +[](https://packagist.org/packages/laravel-notification-channels/smspoh) |
| 4 | +[](LICENSE.md) |
| 5 | +[](https://travis-ci.org/laravel-notification-channels/smspoh) |
| 6 | +[](https://styleci.io/repos/:style_ci_id) |
| 7 | +[](https://insight.sensiolabs.com/projects/:sensio_labs_id) |
| 8 | +[](https://scrutinizer-ci.com/g/laravel-notification-channels/smspoh) |
| 9 | +[](https://scrutinizer-ci.com/g/laravel-notification-channels/smspoh/?branch=master) |
| 10 | +[](https://packagist.org/packages/laravel-notification-channels/smspoh) |
| 11 | + |
| 12 | +This package makes it easy to send notifications using [SmsPoh](https://smspoh.com/) with Laravel 5.5+ and 6.0 |
| 13 | + |
| 14 | +## Contents |
| 15 | + |
| 16 | +- [Installation](#installation) |
| 17 | + - [Setting up the smspoh](#setting-up-the-smspoh-service) |
| 18 | +- [Usage](#usage) |
| 19 | + - [Available Message methods](#available-message-methods) |
| 20 | + - [ On-Demand Notifications](#on-demand-notifications) |
| 21 | +- [Changelog](#changelog) |
| 22 | +- [Testing](#testing) |
| 23 | +- [Security](#security) |
| 24 | +- [Contributing](#contributing) |
| 25 | +- [Credits](#credits) |
| 26 | +- [License](#license) |
| 27 | + |
| 28 | + |
| 29 | +## Installation |
| 30 | + |
| 31 | +You can install this package via composer: |
| 32 | +``` bash |
| 33 | +composer require laravel-notification-channels/smspoh |
| 34 | +``` |
| 35 | + |
| 36 | +### Setting up the Smspoh service |
| 37 | + |
| 38 | +Add your Smspoh token, default sender name (or phone number) to your config/services.php: |
| 39 | + |
| 40 | +```php |
| 41 | +// config/services.php |
| 42 | +... |
| 43 | +'smspoh' => [ |
| 44 | + 'endpoint' => env('SMSPOH_ENDPOINT', 'https://smspoh.com/api/v2/send'), |
| 45 | + 'token' => env('SMSPOH_TOKEN', 'YOUR SMSPOH TOKEN HERE'), |
| 46 | + 'sender' => env('SMSPOH_SENDER', 'YOUR SMSPOH SENDER HERE') |
| 47 | +], |
| 48 | +... |
| 49 | +``` |
| 50 | + |
| 51 | +## Usage |
| 52 | + |
| 53 | +You can use the channel in your via() method inside the notification: |
| 54 | + |
| 55 | +```php |
| 56 | +use Illuminate\Notifications\Notification; |
| 57 | +use NotificationChannels\Smspoh\SmspohMessage; |
| 58 | + |
| 59 | +class AccountApproved extends Notification |
| 60 | +{ |
| 61 | + public function via($notifiable) |
| 62 | + { |
| 63 | + return ["smspoh"]; |
| 64 | + } |
| 65 | + |
| 66 | + public function toSmspoh($notifiable) |
| 67 | + { |
| 68 | + return (new SmspohMessage)->content("Your account was approved!"); |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +In your notifiable model, make sure to include a routeNotificationForSmspoh() method, which returns a phone number or an array of phone numbers. |
| 74 | + |
| 75 | +```php |
| 76 | +public function routeNotificationForSmspoh() |
| 77 | +{ |
| 78 | + return $this->phone; |
| 79 | +} |
| 80 | +``` |
| 81 | +### On-Demand Notifications |
| 82 | +Sometimes you may need to send a notification to someone who is not stored as a "user" of your application. Using the Notification::route method, you may specify ad-hoc notification routing information before sending the notification: |
| 83 | + |
| 84 | +```php |
| 85 | +Notification::route('smspoh', '5555555555') |
| 86 | + ->notify(new InvoicePaid($invoice)); |
| 87 | +``` |
| 88 | +### Available Message methods |
| 89 | + |
| 90 | +`sender()`: Sets the sender's name. *Make sure to register the sender name at you SmsPoh dashboard.* |
| 91 | + |
| 92 | +`content()`: Set a content of the notification message. This parameter should be no longer than 918 char(6 message parts), |
| 93 | + |
| 94 | +`test()`: Send a test message to specific mobile number or not. This parameter should be boolean and default value is `true`. |
| 95 | +## Changelog |
| 96 | + |
| 97 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 98 | + |
| 99 | +## Testing |
| 100 | + |
| 101 | +``` bash |
| 102 | +$ composer test |
| 103 | +``` |
| 104 | + |
| 105 | +## Security |
| 106 | + |
| 107 | +If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
| 108 | + |
| 109 | +## Contributing |
| 110 | + |
| 111 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 112 | + |
| 113 | +## Credits |
| 114 | + |
| 115 | +- [Tint Naing Win](https://github.com/tintnaingwinn) |
| 116 | +- [All Contributors](../../contributors) |
| 117 | + |
| 118 | +## License |
| 119 | + |
| 120 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments