webpacks / notigen
A Laravel package that simplifies the process of creating, managing, and sending custom notifications
Installs: 26
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Blade
pkg:composer/webpacks/notigen
Requires
- php: ^8.2
- illuminate/database: ^8.0|^9.0|^10.0|^11.0
- illuminate/notifications: ^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- mockery/mockery: ^1.4.4
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0|^10.0
README
A Laravel package for managing notification templates with variable support and multiple channel capabilities. Create, manage, and send notifications with a beautiful web interface.
Installation
You can install the package via composer:
composer require ramsheedm/notigen
Setup
- Publish the assets and config:
php artisan vendor:publish --provider="RamsheedM\Notigen\NotigenServiceProvider"
- Run migrations:
php artisan migrate
- Add the service provider to
config/app.phpif not auto-discovered:
'providers' => [ // ... RamsheedM\Notigen\NotigenServiceProvider::class, ], 'aliases' => [ // ... 'Notigen' => RamsheedM\Notigen\Facades\Notigen::class, ]
Usage
1. Web Interface
Access the web interface at /notigen to manage your notification templates:
- Create new templates with variables
- Preview templates with test data
- Manage existing templates
- Configure notification channels
2. Programmatic Usage
Create a Template:
use RamsheedM\Notigen\Facades\Notigen; $template = Notigen::createTemplate([ 'name' => 'Welcome Email', 'template_key' => 'welcome_email', // Optional, will be auto-generated 'content' => 'Hello {user_name}, Welcome to {app_name}!', 'variables' => [ ['name' => 'user_name', 'description' => "User's full name"], ['name' => 'app_name', 'description' => 'Application name'] ], 'channels' => ['mail', 'database'], // Optional, defaults to ['mail'] 'subject' => 'Welcome to {app_name}', // Optional, for email channel 'description' => 'Template for welcome emails' // Optional ]);
Send Notifications:
// Using template key Notigen::send('welcome_email', [ 'user_name' => 'John Doe', 'app_name' => 'My App' ], $user); // $user is the notifiable entity // Or using template object $template = Notigen::getTemplate('welcome_email'); $template->send([ 'user_name' => 'John Doe', 'app_name' => 'My App' ], $user);
Preview Content:
// Preview with variables replaced $content = Notigen::preview('welcome_email', [ 'user_name' => 'John Doe', 'app_name' => 'My App' ]);
Template Management:
// Get all templates $templates = Notigen::getAllTemplates(); // Get a specific template $template = Notigen::getTemplate('welcome_email'); // Update a template Notigen::updateTemplate('welcome_email', [ 'content' => 'New content with {user_name}', 'variables' => [ ['name' => 'user_name', 'description' => 'Updated description'] ] ]); // Delete a template Notigen::deleteTemplate('welcome_email');
Configuration
Configuration options in config/notigen.php:
return [ // Default notification channels 'default_channels' => ['mail'], // Route prefix for the web interface 'route_prefix' => 'notigen', // Middleware for the web interface 'middleware' => ['web', 'auth'], // Database table names 'tables' => [ 'templates' => 'notification_templates', 'variables' => 'template_variables' ] ];
Features
- ✨ Beautiful web interface for template management
- 📝 Variable support with validation
- 📫 Multiple notification channel support
- 🔑 Automatic template key generation
- 🔒 CSRF protection and validation
- 👀 Live preview functionality
- 🚀 Easy integration with existing Laravel apps
- 🎨 Clean and intuitive UI/UX
- ♻️ Event-driven architecture
Contributing
Please see CONTRIBUTING.md for details.
Security
If you discover any security-related issues, please email chatwith@ramsheed.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.