A reusable Filament plugin for sending SMS notifications via multiple drivers.
mcbankske/filament-sms-notifier is a Laravel package for a reusable filament plugin for sending sms notifications via multiple drivers..
It currently has 0 GitHub stars and 15 downloads on Packagist (latest version v1.4.0).
Install it with composer require mcbankske/filament-sms-notifier.
Discover more Laravel packages by mcbankske
or browse all Laravel packages to compare alternatives.
Last updated
Filament SMS Notifier is a flexible and reusable Filament plugin that allows you to send SMS messages using configurable drivers. It includes a simple widget for sending test SMS directly from the Filament admin panel.
.env and config/smsnotifier.phpInstall the package via Composer:
composer require mcbankske/filament-sms-notifier
Publish the configuration file:
php artisan vendor:publish --tag=filament-sms-notifier-config
Add your TextSMS API credentials to your .env file:
SMSNOTIFIER_API_KEY=your_api_key_here
SMSNOTIFIER_PARTNER_ID=your_partner_id_here
SMSNOTIFIER_SHORTCODE=YourBrandName # Optional, defaults to 'TextSMS'
The configuration file config/smsnotifier.php allows you to customize the SMS gateway settings:
return [
'default' => env('SMSNOTIFIER_DRIVER', 'textsms'),
'drivers' => [
'textsms' => [
'api_key' => env('SMSNOTIFIER_API_KEY'),
'partner_id' => env('SMSNOTIFIER_PARTNER_ID'),
'shortcode' => env('SMSNOTIFIER_SHORTCODE', 'TextSMS'),
],
// Add your custom drivers here
],
];
use MCBANKSKE\FilamentSmsNotifier\Facades\SmsNotifier;
// Send an SMS
$response = SmsNotifier::send('254700000000', 'Hello from Filament SMS Notifier!');
if ($response['success']) {
// SMS sent successfully
} else {
// Handle error
logger()->error('Failed to send SMS: ' . $response['message']);
}
// Send an SMS using the helper function
$response = sms('254700000000', 'Hello from the helper function!');
if ($response['success']) {
// SMS sent successfully
} else {
// Handle error
logger()->error('Failed to send SMS: ' . $response['message']);
}
use MCBANKSKE\FilamentSmsNotifier\Services\SmsService;
public function sendWelcomeSms(SmsService $smsService)
{
$phoneNumber = '254700000000'; // E.164 format
$message = 'Welcome to our service!';
$response = $smsService->send($phoneNumber, $message);
if ($response['success']) {
// SMS sent successfully
} else {
// Handle error
logger()->error('Failed to send SMS: ' . $response['message']);
}
}
Add the test SMS widget to any Filament page:
use MCBANKSKE\FilamentSmsNotifier\Filament\Widgets\SendTestSmsWidget;
protected function getHeaderWidgets(): array
{
return [
SendTestSmsWidget::class,
];
}
namespace App\SmsDrivers;
use MCBANKSKE\FilamentSmsNotifier\Contracts\SmsGatewayDriver;
class MyCustomDriver implements SmsGatewayDriver
{
public function send(string $to, string $message): array
{
// Your implementation here
return [
'success' => true,
'message' => 'SMS sent successfully',
'data' => [/* response data */]
];
}
}
config/smsnotifier.php:'drivers' => [
'textsms' => [
// ... existing config
],
'mycustom' => [
'driver' => 'mycustom',
// Add any custom configuration
],
],
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
2. Register your driver in a service provider's `boot` method:
```php
use App\SmsDrivers\MyCustomDriver;
use MCBANKSKE\FilamentSmsNotifier\Services\SmsService;
public function boot()
{
app()->when(MyCustomDriver::class)
->needs('$config')
->giveConfig('smsnotifier.drivers.my-custom');
app(SmsService::class)->extend('my-custom', function ($app) {
return new MyCustomDriver(config('smsnotifier.drivers.my-custom'));
});
}
filament-sms-notifier/
βββ config/ # Configuration files
β βββ smsnotifier.php # Main configuration
βββ src/ # Source files
β βββ Contracts/ # Interfaces
β β βββ SmsGatewayDriver.php
β βββ Drivers/ # Built-in drivers
β β βββ TextSmsGatewayDriver.php
β βββ Services/ # Core services
β β βββ SmsService.php
β βββ Filament/ # Filament integration
β β βββ Widgets/
β β βββ SendTestSmsWidget.php
β βββ SmsNotifierServiceProvider.php # Service provider
βββ resources/ # Views and assets
βββ views/
βββ widgets/
βββ send-test-sms-widget.blade.php
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is open-sourced under the MIT License.