PHPackages                             humweb/notification-subscriptions - 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. humweb/notification-subscriptions

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

humweb/notification-subscriptions
=================================

This is my package notification-subscriptions

01.2k↓72.6%[3 PRs](https://github.com/humweb/notification-subscriptions/pulls)PHPCI passing

Since May 23Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/humweb/notification-subscriptions)[ Packagist](https://packagist.org/packages/humweb/notification-subscriptions)[ RSS](/packages/humweb-notification-subscriptions/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependenciesVersions (7)Used By (0)

Notification Subscriptions for Laravel
======================================

[](#notification-subscriptions-for-laravel)

[![Tests](https://github.com/humweb/notification-subscriptions/actions/workflows/run-tests.yml/badge.svg)](https://github.com/humweb/notification-subscriptions/actions/workflows/run-tests.yml)[![codecov](https://camo.githubusercontent.com/4ad9a649ff0a23fc0c07c8d7939845e2283a9d53b291141140e97acfa3e20d57/68747470733a2f2f636f6465636f762e696f2f67682f68756d7765622f6e6f74696669636174696f6e2d737562736372697074696f6e732f67726170682f62616467652e737667)](https://codecov.io/gh/humweb/notification-subscriptions)[![Code Style](https://github.com/humweb/notification-subscriptions/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/humweb/notification-subscriptions/actions/workflows/fix-php-code-style-issues.yml)[![PHPStan](https://github.com/humweb/notification-subscriptions/actions/workflows/phpstan.yml/badge.svg)](https://github.com/humweb/notification-subscriptions/actions/workflows/phpstan.yml)

Notification Subscriptions allows your users to subscribe to certain notifications in your application, with support for per-channel preferences and notification digests (daily/weekly summaries).

**For full documentation, please see the [docs/index.md](./docs/index.md) page.**

Quick Links
-----------

[](#quick-links)

- [Installation](./docs/installation.md)
- [Configuration](./docs/configuration.md)
- [Usage](./docs/usage/subscribable-trait.md)
- [Usage](./docs/usage/subscribable-trait.md)
    - [Digest System (with structured builder)](./docs/usage/digest-system.md)
- [License](./docs/license.md)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require humweb/notification-subscriptions
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="notification-subscriptions-migrations"
php artisan migrate
```

This will create two tables:

- `notification_subscriptions`: Stores user subscriptions, including channel and digest preferences.
- `pending_notifications`: Temporarily stores notifications that are scheduled for digest delivery.

You can publish the config file with:

```
php artisan vendor:publish --tag="notification-subscriptions-config"
```

This will create a `config/notification-subscriptions.php` file.

Setup
-----

[](#setup)

### 1. Prepare Your User Model

[](#1-prepare-your-user-model)

Add the `Humweb\\Notifications\\Traits\\Subscribable` trait to your `User` model (or any model you want to make subscribable).

```
namespace App\\Models;

use Humweb\\Notifications\\Traits\\Subscribable;
use Illuminate\\Foundation\\Auth\\User as Authenticatable;
use Illuminate\\Notifications\\Notifiable; // Usually already present

class User extends Authenticatable
{
    use Notifiable, Subscribable; // Add Subscribable here

    // ... rest of your User model
}
```

### 2. Configure Notification Types

[](#2-configure-notification-types)

Open the `config/notification-subscriptions.php` file. This is where you define all the notification types users can subscribe to, their available channels, and digest settings.

```
