apxcde / laravel-onfon-sms
Add OnFon SMS to your laravel web application
Fund package maintenance!
apxcde
Installs: 1 651
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- ext-curl: *
- illuminate/contracts: ^9.3
- spatie/laravel-package-tools: ^1.11.2
Requires (Dev)
- nunomaduro/collision: ^6.1.0
- orchestra/testbench: ^7.1
- pestphp/pest: ^1.18
- pestphp/pest-plugin-laravel: ^1.1
- spatie/laravel-ray: ^1.29
- vimeo/psalm: ^4.22
This package is auto-updated.
Last update: 2025-02-23 23:44:24 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require apxcde/laravel-onfon-sms
Publish the config file
You can publish the config file with:
php artisan vendor:publish --provider="Apxcde\OnfonSms\OnfonSmsServiceProvider" --tag="onfon-sms-config"
This is the contents of the published config file:
return [ 'senderId' => env('ONFON_SMS_SENDER_ID', ''), 'api_key' => env('ONFON_SMS_API_KEY', ''), 'client_id' => env('ONFON_SMS_CLIENT_ID', ''), 'access_key' => env('ONFON_SMS_ACCESS_KEY', ''), ];
Add Environment Variables
Set the variables below in your .env file. You will receive these variables from onfon media
ONFON_SMS_SENDER_ID="" ONFON_SMS_API_KEY="" ONFON_SMS_CLIENT_ID="" ONFON_SMS_ACCESS_KEY=""
Set up the notifiable model
Add the routeNotificationForOnfon method on your notifiable Model. If this is not added, the phone_number field will be automatically used.
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * Route notifications for the OnFon channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ public function routeNotificationForOnfon($notification) { return $this->phone; } }
Usage
To use this package, you need to create a notification class, like NewsWasPublished from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.
<?php use Apxcde\OnfonSms\OnfonChannel; use Apxcde\OnfonSms\OnfonMessage; class NewsWasPublished extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [OnfonChannel::class]; } public function toOnfon($notifiable) { return (new OnfonMessage()) ->content('Your SMS message content'); } }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover any security-related issues, please email erick@apexcode.dev instead of using the issue tracker.