PHPackages                             amjitk/laravel-global-notification - 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. amjitk/laravel-global-notification

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

amjitk/laravel-global-notification
==================================

A comprehensive notification system for Laravel with CMS and automated triggers.

2.0.0(3mo ago)02MITBladePHP ^8.1

Since Dec 18Pushed 3mo agoCompare

[ Source](https://github.com/Amjitk/laravel-global-notification)[ Packagist](https://packagist.org/packages/amjitk/laravel-global-notification)[ RSS](/packages/amjitk-laravel-global-notification/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (5)Used By (0)

 [![Global Notification Logo](resources/img/logo.png)](resources/img/logo.png)

Laravel Global Notification
===========================

[](#laravel-global-notification)

A comprehensive notification system for Laravel applications. This package allows you to manage notification types and templates via a CMS and automatically trigger them based on system events.

Features
--------

[](#features)

- **CMS Interface**: Manage types, define variables, and test templates directly from the admin panel.
- **Multi-Channel Support**: Configure different templates for different channels for the same event.
- **User Preference Center**: Users can toggle specific notification channels on/off.
- **Auto-Triggering**: Automatically fire notifications on Eloquent model events (created, updated, etc.).
- **In-App Toast Widget**: Real-time polling widget to show notifications instantly.
- **User Notification Center**: Built-in UI for users to view and manage their in-app notifications.
- **Dynamic Content**: Use placeholders like `{{name}}` in your templates.

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

[](#installation)

1. Install the package via Composer:

    ```
    composer require amjitk/laravel-global-notification
    ```

    *Note: If testing locally without Packagist, configure your `composer.json` repositories to point to the local path.*
2. Run Migrations:

    ```
    php artisan migrate
    ```
3. (Optional) Publish Configuration and Assets:

    ```
    php artisan vendor:publish --tag=global-notification-config
    php artisan vendor:publish --tag=global-notification-views
    ```

Configuration
-------------

[](#configuration)

The configuration file `config/global-notification.php` allows you to customize:

- **Channels**: Enabled channels (default: `mail`, `database`).
- **Route Prefix**: URL prefix for the package routes (default: `global-notification`).
- **Middleware**: Middleware for admin routes. Configurable via `.env`: ```
    GLOBAL_NOTIFICATION_AUTH_ENABLED=true # Set to false to disable authentication
    ```

Usage
-----

[](#usage)

### 1. Admin - Manage Notifications

[](#1-admin---manage-notifications)

Visit `/global-notification/notification-types` to create new Notification Types (e.g., `order_placed`).

- **Variables**: Define available variables (e.g. `order_id, amount`) when creating a Type.
- **Templates**: Create templates for each channel. Use the defined variables (e.g. `{{ amount }}`).
- **Testing**: Use the "**Send Test**" button on any template to send a dummy notification to yourself immediately.

### 2. Triggering Notifications

[](#2-triggering-notifications)

#### Manual Trigger

[](#manual-trigger)

Use the `NotificationService` to send a notification programmatically:

```
use AmjitK\GlobalNotification\Services\NotificationService;

$service = new NotificationService();
$service->send('order_placed', $user, ['order_id' => 123, 'amount' => '$50']);
```

#### Automatic Trigger (Model Events)

[](#automatic-trigger-model-events)

Add the `AutoNotifyTrait` to your Eloquent model:

```
use AmjitK\GlobalNotification\Traits\AutoNotifyTrait;

class Order extends Model
{
    use AutoNotifyTrait;

    // Map system events to Notification Type keys
    public $notificationRules = [
        'created' => 'order_placed',   // Fires 'order_placed' when Order is created
        'updated' => 'order_updated',  // Fires 'order_updated' when Order is updated
    ];
}
```

### 3. Notification Logs

[](#3-notification-logs)

View all system notifications at: `/global-notification/logs`

This page displays a global log of all notifications triggered in the system.

### 4. Scheduled Notifications

[](#4-scheduled-notifications)

You can schedule notifications using the package's `send` method combined with Laravel's Scheduler. This creates a powerful workflow where you can define templates in the CMS types and trigger them via Cron jobs.

**Why use the package's `send` method instead of `Notification::send` or `Mail::send`?**Using `$service->send()` allows you to:

1. **Use CMS Templates**: Manage the content of your scheduled emails/alerts dynamically without deploying code.
2. **Separate Logging**: By tagging them with `withSource('scheduled')`, they appear in the dedicated **Scheduled Logs** dashboard, separating them from transactional or user alerts.

**Example: Sending a Daily Digest**

```
// app/Console/Kernel.php or app/Console/Commands/SendDailyDigest.php

use AmjitK\GlobalNotification\Services\NotificationService;

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        $service = app(NotificationService::class);
        $users = \App\Models\User::all();

        foreach ($users as $user) {
            // 'daily_digest' is a Notification Type defined in your CMS
            $service->withSource('scheduled')
                    ->send('daily_digest', $user, [
                        'date' => now()->toFormattedDateString(),
                        'stats' => $user->getDailyStats()
                    ]);
        }
    })->dailyAt('09:00');
}
```

### 5. In-App Widget (Toast)

[](#5-in-app-widget-toast)

To display a real-time toast notification in your application whenever a new notification arrives:

1. Make sure you have published the views (or reference the package view).
2. Add the following line to your main layout file (e.g., `resources/views/layouts/app.blade.php`), preferably just before the closing `` tag:

    ```
    @include('global-notification::components.toast')
    ```
3. Ensure your application layout includes Alpine.js or vanilla JS support (the component uses vanilla JS but allows for easy customization).

### 6. User Preferences

[](#6-user-preferences)

Users can manage their notification preferences (opt-in/out of specific channels) by visiting: `/global-notification/preferences`

- The interface allows users to toggle channels (e.g., turn off Email for "Order Updates" but keep it for "Promotions").
- The system automatically checks these preferences before sending any notification.

Testing
-------

[](#testing)

To run the package tests:

```
composer install
vendor/bin/phpunit
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance80

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~13 days

Total

4

Last Release

104d ago

Major Versions

1.2.0 → 2.0.02026-01-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/62fc496d0b4499c581e121467b6840dc741bd692abc6256373ae0d7c9377c9d7?d=identicon)[amjitk](/maintainers/amjitk)

---

Top Contributors

[![Amjitk](https://avatars.githubusercontent.com/u/96902489?v=4)](https://github.com/Amjitk "Amjitk (7 commits)")[![amjithcubet](https://avatars.githubusercontent.com/u/126227433?v=4)](https://github.com/amjithcubet "amjithcubet (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/amjitk-laravel-global-notification/health.svg)

```
[![Health](https://phpackages.com/badges/amjitk-laravel-global-notification/health.svg)](https://phpackages.com/packages/amjitk-laravel-global-notification)
```

###  Alternatives

[beyondcode/laravel-mailbox

Handle incoming emails in your Laravel application.

1.1k1.0M4](/packages/beyondcode-laravel-mailbox)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[illuminate/mail

The Illuminate Mail package.

5910.1M391](/packages/illuminate-mail)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[therobfonz/laravel-mandrill-driver

Mandrill Driver for Laravel

773.5M](/packages/therobfonz-laravel-mandrill-driver)

PHPackages © 2026

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