PHPackages                             owowagency/laravel-nofitication-bundler - 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. owowagency/laravel-nofitication-bundler

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

owowagency/laravel-nofitication-bundler
=======================================

Bundle multiple notifications into one

1.1.0(2y ago)13MITPHPPHP ^8.2

Since Dec 5Pushed 2y ago4 watchersCompare

[ Source](https://github.com/owowagency/laravel-notification-bundler)[ Packagist](https://packagist.org/packages/owowagency/laravel-nofitication-bundler)[ Docs](https://github.com/owowagency/laravel-notification-bundler)[ RSS](/packages/owowagency-laravel-nofitication-bundler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (13)Versions (4)Used By (0)

[![banner-dark](.github/assets/banner-dark.svg#gh-dark-mode-only)](.github/assets/banner-dark.svg#gh-dark-mode-only)[![banner-light](.github/assets/banner-light.svg#gh-light-mode-only)](.github/assets/banner-light.svg#gh-light-mode-only)

 [ ![Release shield](https://camo.githubusercontent.com/4b713b7829eb05e1defd1a49f4256359f870acb8248719aed0dfcad62c67e122/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f776f776167656e63792f6c61726176656c2d6e6f74696669636174696f6e2d62756e646c65722e7376673f6c6f676f3d676974687562) ](https://github.com/owowagency/laravel-notification-bundler/releases) [ ![Workflow shield](https://camo.githubusercontent.com/24ac202076c1e9baff2fcb71ab6f856dd1e6ab5b68156c6fa5a186beb54dc386/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f776f776167656e63792f6c61726176656c2d6e6f74696669636174696f6e2d62756e646c65722f746573742e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473266c6f676f3d676974687562) ](https://github.com/owowagency/laravel-notification-bundler/actions/workflows/test.yml?query=branch%3Amain) [ ![Downloads shield](https://camo.githubusercontent.com/b5ec60101490a71b93e92bb6db53e1e8a123c203098a4243291c00f2b6f0f5ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f776f776167656e63792f6c61726176656c2d6e6f74696669636174696f6e2d62756e646c65722e7376673f6c6f676f3d7061636b6167697374) ](https://packagist.org/packages/owowagency/laravel-notification-bundler)

 A package for Laravel that bundles notifications sent within a specified delay for a single user.

📖 Table of contents
===================

[](#-table-of-contents)

1. [Installation](#-installation)
2. [Usage](#-usage)
    1. [Limitations](#limitations)
    2. [Changing the delay](#changing-the-delay)
    3. [Specify the channels to bundle](#specify-the-channels-to-bundle)[Contributing](#-contributing)
3. [License](#-license)
4. [OWOW](#-owow)

⚙️ Installation
---------------

[](#️-installation)

Installing this package can be done by using `Composer`:

```
composer require owowagency/laravel-notification-bundler
```

🛠️ Usage
--------

[](#️-usage)

Here is a simple example of how to use this package.

```
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Collection;
use Owowagency\NotificationBundler\BundlesNotifications;
use Owowagency\NotificationBundler\ShouldBundleNotifications;

class BundledMailNotification extends Notification implements ShouldBundleNotifications, ShouldQueue
{
    use BundlesNotifications, Queueable;

    public function __construct(public string $name)
    {
        //
    }

    /**
     * The channels the notification should be sent on.
     */
    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     * This replaces the original `toMail` method and adds the $notifications
     * collection as the last parameter.
     */
    public function toMailBundle(object $notifiable, Collection $notifications)
    {
        $message = (new MailMessage)
            ->subject('Bundle');

        foreach ($notifications as $notification) {
            $message->line("$notification->name was bundled.");
        }

        return $message;
    }

    /**
     * Returns the identifier for the bundle.
     * This is used to determine which notifications should be bundled together.
     * This also means that different notifications can be bundled together.
     */
    public function bundleIdentifier(object $notifiable): string
    {
        return "user_$notifiable->id";
    }
}
```

Limitations
-----------

[](#limitations)

Because of limitations in Laravel, the database channel must implicitly use the `toArray`, or `toDatabase` method. To get the notifications in those functions, you can use the `getBundle()` method.

```
public function toDatabase(object $notifiable): array
{
    $notifications = $this->getBundle();
    return ['names' => $notifications->pluck('name')->toArray()];
}
```

When you want to add custom middleware, it is important to always apply the bundle middleware first. If you don't do this, your notification could be bundled with a another notification later on, which can cause unexpected results.

```
class CustomMiddlewareNotification extends Notification implements ShouldBundleNotifications, ShouldQueue
{
    use BundlesNotifications {
        middleware as bundledMiddleware;
    }

    // ...

    public function middleware(object $notifiable): array
    {
        return [
            ...$this->bundledMiddleware($notifiable), // First apply the bundled middleware.
            StopExecution::class, // Then apply your own middleware.
        ];
    }
}
```

### Changing the delay

[](#changing-the-delay)

By default, the delay is set to 30 seconds. You can change this delay by publishing the config file and changing the `bundle_notifications_after_seconds` value.

```
php artisan vendor:publish --provider="Owowagency\NotificationBundler\NotificationBundlerServiceProvider" --tag="config"
```

To change it per notification, the `bundleDelay()` method can be used.

```
public function bundleDelay(object $notifiable): int|\DateTimeInterface
{
    return 60;
}
```

To take even more control, you can use the `withDelay()` method to specify a delay per channel.

```
public function withDelay(object $notifiable): array
{
    return [
        'mail' => 30,
        'sms' => 60,
    ];
}
```

### Specify the channels to bundle

[](#specify-the-channels-to-bundle)

By default, all channels are bundled. You can change this by using the `bundleChannels()` method.

```
public function bundleChannels(): array
{
    return ['mail'];
}
```

🫶 Contributing
--------------

[](#-contributing)

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

📜 License
---------

[](#-license)

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

[![](.github/assets/owow-light.svg#gh-light-mode-only)](.github/assets/owow-light.svg#gh-light-mode-only)

[![](.github/assets/owow-dark.svg#gh-dark-mode-only)](.github/assets/owow-dark.svg#gh-dark-mode-only)

This package has been brought to you with much love by the wizkids of [OWOW](https://owow.io/). Do you like this package? We’re still looking for new talent and Wizkids. So do you want to contribute to open source, while getting paid? [Apply now](https://owow.io/careers).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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 ~18 days

Total

3

Last Release

854d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c2baff8052ff4d3fdf2697fba4a31b7fb926bdc1d372eaccab8cb11f9a37f2a?d=identicon)[thomasowow](/maintainers/thomasowow)

---

Top Contributors

[![Sjoertjuh](https://avatars.githubusercontent.com/u/63722509?v=4)](https://github.com/Sjoertjuh "Sjoertjuh (24 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (3 commits)")

---

Tags

laravelnotificationsOWOWlaravel-notification-bundler

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/owowagency-laravel-nofitication-bundler/health.svg)

```
[![Health](https://phpackages.com/badges/owowagency-laravel-nofitication-bundler/health.svg)](https://phpackages.com/packages/owowagency-laravel-nofitication-bundler)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k49.4M479](/packages/laravel-scout)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel/pennant

A simple, lightweight library for managing feature flags.

57311.1M53](/packages/laravel-pennant)

PHPackages © 2026

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