Download the PHP package eugenefvdm/notification-subscriptions without Composer
On this page you can find all versions of the php package eugenefvdm/notification-subscriptions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eugenefvdm/notification-subscriptions
More information about eugenefvdm/notification-subscriptions
Files in eugenefvdm/notification-subscriptions
Package notification-subscriptions
Short Description A Laravel package for managing email subscriptions, repeat emails, and delayed sending
License MIT
Informations about the package notification-subscriptions
Notification Subscriptions
Notification Subscriptions is a Laravel package that may be used to keep track of repeat emails, delayed emails, and unsubscribing of email notifications.
The package makes use of Laravel's built-in event listeners NotificationSending
and NotificationSent
to automatically subscribe and to determine if and when a message should be sent.
Categorization of emails and model specific subscriptions are possible.
Requirements
- Laravel 11 or 12
Installation
After installing the package, run the migrations:
This will create the notification_templates
and notification_subscriptions
tables.
If you want to customize the unsubscribe link or unsubscribed
confirmation blade, publish the views:
User Model
Add the HasNotificationSubscriptions
trait to your User
model:
Usage
Generate notifications as per usual using php artisan
:
Extend the newly created notification with the BaseNotification class:
Repeat Settings
In your notification class, add any or all of the following variables to do repeated notifications:
Delayed Sending
To wait a certain amount of time before sending a notification, set initialDelay
in your constructor:
Categorization
All new messages without an explicit category assignment will be assigned to the default
category in the database.
To specify a custom category, use $category
:
Model Specific Subscriptions
Notifications are typically tied to a user, but at times one wants to associate a notification to both a user and another model. For example, you might have a products
table, and you want a user to be subscribed to a price notification for specific Product
models. Here's how:
Unsubscribe
Any new notification will be automatically subscribed when used the first time.
Adding the Unsubscribe Link in Blades
For unsubscribe links, modify the toMail
method in the notification class:
Then add this to your blade:
The invokable controller for unsubscribe will direct the user to a generic unsubcribed.blade.php
file that may be customized. The variables returned to this blade are:
Possible $message
values are:
- Subscription not found
- The $template->name_with_spaces notification cannot be unsubscribed
- You are already unsubscribed from the '$template->name_with_spaces' notification
- Successfully unsubscribed from the '$template->name_with_spaces' notification
Testing
License
The MIT License (MIT). Please see License File for more information.
Alternatives
- mail-tracker - A Laravel package that injects tracking code into outgoing emails and provides an interface to view sent emails, track opens, and monitor link clicks.