PHPackages                             asantibanez/laravel-subscribable-notifications - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. asantibanez/laravel-subscribable-notifications

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

asantibanez/laravel-subscribable-notifications
==============================================

Laravel Subscribable Notifications

v1.0.6(10mo ago)14422.1k↓34.6%5[3 PRs](https://github.com/asantibanez/laravel-subscribable-notifications/pulls)MITPHPPHP ^7.4|^8.0|^8.1|^8.2CI failing

Since Oct 7Pushed 10mo ago8 watchersCompare

[ Source](https://github.com/asantibanez/laravel-subscribable-notifications)[ Packagist](https://packagist.org/packages/asantibanez/laravel-subscribable-notifications)[ Docs](https://github.com/asantibanez/laravel-subscribable-notifications)[ RSS](/packages/asantibanez-laravel-subscribable-notifications/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (4)Versions (8)Used By (0)

Laravel Subscribable Notifications
==================================

[](#laravel-subscribable-notifications)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3850094cba76ab807c545c0678daf8415916bb9a2a75b09e86e7f5e2d9644006/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6173616e746962616e657a2f6c61726176656c2d737562736372696261626c652d6e6f74696669636174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asantibanez/laravel-subscribable-notifications)[![Total Downloads](https://camo.githubusercontent.com/aa743099d80251a6a0ae70c89746a210091b7b5433716ee9b3a4690f69215582/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6173616e746962616e657a2f6c61726176656c2d737562736372696261626c652d6e6f74696669636174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asantibanez/laravel-subscribable-notifications)[![GitHub Actions](https://github.com/asantibanez/laravel-subscribable-notifications/actions/workflows/main.yml/badge.svg)](https://github.com/asantibanez/laravel-subscribable-notifications/actions/workflows/main.yml/badge.svg)

This package allows you to subscribe your app Users to your app Notifications and dispatch them without specifying the recipient. The main goal of this package is allowing you to create "lists of recipients" for your Notification classes and dispatch notifications to your users easily.

### Motivation

[](#motivation)

Recently I've been developing back-office kind of apps where a group of users need to be notified via email for a particular event or scenario in the system. These users were being hardcoded in the app and sometimes they needed to subscribe or be removed from certain emails, depending on the job they were doing at the company. Since their emails were hardcoded, it was tricky to update the "subscribers" list to each mailable that was sent by the application. With that idea in mind, this package was created to allow configuring users to each mailable they need to receive.

### Installation

[](#installation)

You can install the package via composer:

```
composer require asantibanez/laravel-subscribable-notifications
```

Afterwards, export both the `config` and `migrations` by using the `php artisan vendor:publish` command.

Once the `laravel-subscribable-notifications.php` config file is exported, make sure you define your `User` model and your `subscribable_notifications` (more on this below). Only the notifications you configure will be available for subscription.

### Usage

[](#usage)

Using Laravel notifications system, you normally dispatch notifications using the `Notification` facade or via the `User`model `notify()` method when implementing the `Notifiable` trait.

```
Notification::send([$user1, $user2, $user3], new OrderShipped($order));

// or
$notification = new OrderShipped($order);

$user1->notify($notification);
$user2->notify($notification);
$user3->notify($notification);
```

With `laravel-subscribable-notifications`, you send the notification by "dispatching" it. Any subscribed user to the notification will receive it.

```
OrderShipped::dispatch($order);
```

### Preparing your Notifications

[](#preparing-your-notifications)

Notifications must implement the `SubscribableNotification` interface which will require to implement the following methods:

- dispatch
- subscribers
- subscribableNotificationType

For these, add the `DispatchesToSubscriber` trait to your notification which will cover `dispatch` and `subscribers`. Lastly, implement `subscribableNotificationType` by providing a string that identifies your notification. This value will be saved in the database for your users subscriptions.

```
class SalesOrderApprovedNotification extends Notification implements SubscribableNotification
{
    use DispatchesToSubscribers;

    public static function subscribableNotificationType(): string
    {
        return 'sales-order.approved';
    }

    // notification implementation here
}
```

You must also add your notification to the `subscribable_notifications` array inside `laravel-subscribable-notifications` config. Registering your notification here will allow the package to know which notifications can be dispatched throughout this interface.

### Subscribing/Unsubscribing Users

[](#subscribingunsubscribing-users)

Under the hood, a `notification_subscriptions` table is used to track all user subscriptions to your notifications.

Using the `NotificationSubscriptionManager` facade, you can subscribe and unsubscribe users from notification using the `subscribe` and `unsubscribe` methods respectively. There's also a `unsubscribeFromAll` method to remove all subscription from a user.

> Note: Your `User` model can implement the `HasNotificationSubscriptions` trait to get helper methods in order to know what subscriptions each user has been subscribed to.

### Utilities

[](#utilities)

The package register a new `subscribable-notifications:manage` command which you can run in your terminal and interact with the `notification_subscriptions` table. The command allows you to list/add/remove users from notifications you've defined in the `laravel-subscribable-notifications` config file.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Andrés Santibáñez](https://github.com/asantibanez)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance53

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 58.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~225 days

Recently: every ~260 days

Total

7

Last Release

329d ago

PHP version history (3 changes)v1.0.0PHP ^7.4|^8.0

v1.0.3PHP ^7.4|^8.0|^8.1

v1.0.5PHP ^7.4|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/6baeed3442964d13790677923669ee09a0398f638c45ae23b84be71f57150d65?d=identicon)[asantibanez](/maintainers/asantibanez)

---

Top Contributors

[![asantibanez](https://avatars.githubusercontent.com/u/5126648?v=4)](https://github.com/asantibanez "asantibanez (18 commits)")[![Christopher-Law](https://avatars.githubusercontent.com/u/25482861?v=4)](https://github.com/Christopher-Law "Christopher-Law (5 commits)")[![JacobBennett](https://avatars.githubusercontent.com/u/1517011?v=4)](https://github.com/JacobBennett "JacobBennett (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![lukebouch](https://avatars.githubusercontent.com/u/25229123?v=4)](https://github.com/lukebouch "lukebouch (2 commits)")

---

Tags

asantibanezlaravel-subscribable-notifications

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/asantibanez-laravel-subscribable-notifications/health.svg)

```
[![Health](https://phpackages.com/badges/asantibanez-laravel-subscribable-notifications/health.svg)](https://phpackages.com/packages/asantibanez-laravel-subscribable-notifications)
```

###  Alternatives

[mckenziearts/laravel-notify

Flexible flash notifications for Laravel

1.7k1.1M5](/packages/mckenziearts-laravel-notify)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[illuminate/mail

The Illuminate Mail package.

5910.1M391](/packages/illuminate-mail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
