Download the PHP package pschocke/laravel-notification-settings without Composer
On this page you can find all versions of the php package pschocke/laravel-notification-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pschocke/laravel-notification-settings
More information about pschocke/laravel-notification-settings
Files in pschocke/laravel-notification-settings
Package laravel-notification-settings
Short Description Let users decide on what event they want to be notified over which way
License MIT
Homepage https://github.com/pschocke/laravel-notification-settings
Informations about the package laravel-notification-settings
Laravel Notification Settings
This package tries to extend the default laravel notification system by giving models the ability to set individual notification settings for different ways of contact.
Installation
You can install the package via composer:
Publish and run the migration:
Publish the config file:
Usage
This package is driver based. By default, it can only send mail notifications. However, adding driver is a breeze.
To configure the package, you first need to publish the configuration file. It looks like this:
If you want to configure different settings for different models, just add a setting in the array:
If you want to have different settings for different notification channels for a model, simply add an array with the notification key and the settings:
Prepare your model
All models that should have notification settings need to use the pschocke\NotificationSettings\HasNotificationSettings
trait.
Add a new NotificationSetting to a model
To add a notification Channel to a model, just call the saveNotificationSetting()
method on that model with the array of settings:
Sending notifications
To send a notification to a model, just call the sendNotification()
method on the model. The notification will be send through all channels that have the setting on true:
Write your own notification Handler
Just sending notifications via email might be enough, but some times you want to send notifications via other channels too. Luckily, adding more handler is a breeze.
Just create a new handler that implements the pschocke\NotificationSettings\Handler\HandlerInterface
and extends the pschocke\NotificationSettings\Handler
base class.
Just take a look at this handler that sends slack notifications:
After adding the handler you just need to add it to the handlers array in your config file:
Testing
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- :author_name
- All Contributors
License
The MIT License (MIT). Please see License File for more information.