Download the PHP package scabarcas/laravel-notify-matrix without Composer
On this page you can find all versions of the php package scabarcas/laravel-notify-matrix. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scabarcas/laravel-notify-matrix
More information about scabarcas/laravel-notify-matrix
Files in scabarcas/laravel-notify-matrix
Package laravel-notify-matrix
Short Description Manage per-user notification preferences in Laravel, with channel-level opt-in and opt-out.
License MIT
Informations about the package laravel-notify-matrix
Laravel Notify Matrix
Manage per-user notification preferences in Laravel. Each user can opt in or out of channels for each notification group.
Installation
Quick start
Add the trait to the user model (or any notifiable):
Tag each notification with the group it belongs to:
Read and write preferences from the model:
With the trait on the notifiable and the attribute on the notification, the dispatch listener filters channels according to stored preferences. Forced channels are always delivered.
Configuration
Forced channels
Channels listed under groups.<group>.forced are delivered even when the user has opted out. Common use cases are security alerts and account verification messages.
Class map
Third-party notification classes that cannot be annotated with #[NotificationGroup] can be mapped to a group through the class_map entry. Annotated classes always take precedence over the map.
How it works
The package registers a listener for Illuminate\Notifications\Events\NotificationSending that runs before each channel dispatch:
- If the notifiable does not use
HasNotificationPreferences, the listener does not interfere. - If the notification has neither a
#[NotificationGroup]attribute nor aclass_mapentry, the listener does not interfere. - If the channel is listed as forced for the group, the channel is delivered.
- If the user has a stored preference for the channel, that value decides.
- Otherwise, the group default policy decides (or the global default if the group has none).
Testing
Author
Sebastian Cabarcas Berrio · @scabarcas17
License
MIT © Sebastian Cabarcas Berrio
All versions of laravel-notify-matrix with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/notifications Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0