ibnuhalimm / laravel-thai-bulk-sms
Thai Bulk SMS Wrapper for Laravel
Installs: 1 005
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.3|^8.0
- guzzlehttp/guzzle: ^6.5.5|^7.0
- illuminate/support: ~6.0|~7.0|~8.0|~9.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
Laravel wrapper for Thai Bulk SMS.
Contents
Requirements
- Sign Up for the Thai Bulk SMS Account
- Create a Api Key and Secret Key in Setting section
Installation
You can install the package via composer:
composer require ibnuhalimm/laravel-thai-bulk-sms
Optionally, you can publish the config file of this package with this command:
php artisan vendor:publish --provider="Ibnuhalimm\LaravelThaiBulkSms\ThaiBulkSmsServiceProvider"
Setting up
Put your API Key
, Secret Key
, and THAI_BULK_SENDER
to .env
file:
THAI_BULK_API_KEY= THAI_BULK_SECRET_KEY= THAI_BULK_SENDER=
Usage
-
You can directly use the
ThaiBulkSms
Facade (the alias or class itself):use Ibnuhalimm\LaravelThaiBulkSms\Facades\ThaiBulkSms; // Send the sms to single recipient $phoneNumber = '+6612345678'; $message = 'Hi, our message here.'; ThaiBulkSms::send($phoneNumber, $message); // Send the sms to multiple phone number $phoneNumber = [ '+6612345678', '+6690111213', ]; $message = 'Hi, our message here.'; ThaiBulkSms::send($phoneNumber, $message);
The response format of this method will be like Thai Bulk SMS API's Response.
-
Notifications
Let's take a look at the implementation as Notifications Channel.use Ibnuhalimm\LaravelThaiBulkSms\ThaiBulkSmsChannel; use Ibnuhalimm\LaravelThaiBulkSms\ThaiBulkSmsMessage; use Illuminate\Notifications\Notification; class VerifyMobileNumber extends Notification { public function via() { return [ThaiBulkSmsChannel::class]; } public function toThaiBulkSms($notifiable) { return (new ThaiBulkSmsMessage()) ->message("Your OTP to complete the registration is {$this->otp}"); } }
In order to let the notification know which mobile phone number are you sending to, by default the channel will look for the
mobile_number
attribute of Notifiable model. If you want to override this behaviour, add therouteNotificationForThaiBulkSms
method in your Notifiable model.public function routeNotificationForThaiBulkSms() { return $this->phone; }
or set the recipient mobile number directly to the notifiable instance using
to
method... public function toThaiBulkSms($notifiable) { return (new ThaiBulkSmsMessage()) ->message("Your OTP to complete the registration is {$notifiable->otp}") ->to($notifiable->phone); // add this } ...
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email ibnuhalim@pm.me instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.