premgthb / exabytes-sms
Laravel package for generating SMS using Exabytes API
Installs: 2 385
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-12-18 11:18:37 UTC
README
composer require premgthb/exabytes-sms
USAGE
Publish config files:
php artisan vendor:publish --provider="Premgthb\ExabytesSms\ExabytesServiceProvider"
.env Values:
EXABYTES_SMS_USERNAME = Your account username EXABYTES_SMS_PASSWORD = Your account password
Set up Notification class in your Laravel application using
php artisan make:notification ExabytesSmsNotification
and copy the code as follows
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Premgthb\ExabytesSms\Notifications\ExabytesSmsChannel; class ExabytesSmsNotification extends Notification { use Queueable; public $content; public function __construct($message) { $this->message = $message; } /** * Get the notification's delivery channels. */ public function via($notifiable) { return [ExabytesSmsChannel::class]; } /** * Get SMS Message content */ public function toExabytes($notifiable) { return $this->message; } }
In your User.php model:
public function routeNotificationForExabytes() { return preg_replace('/\D+/', '', '6'.$this->mobile_number); }
Finally use the following snippet in your controllers to trigger the Notification
Notification::route('exabytes', $mobileNumber)->notify(new ExabytesSmsNotification($yourMessage));
You are good to go!
ADDITIONAL
To generate 4 digit OTP code, in your controller:
use Exabytes; $otp = Exabytes::generateOtp();
To Send SMS without Queue:
$data = [ 'to' => $request->mobile_number , 'msg' => $request->message ] Exabytes::sendMessage($data);