PHPackages                             jeremykenedy/laravel-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. jeremykenedy/laravel-notifications

ActiveLibrary

jeremykenedy/laravel-notifications
==================================

A Laravel package providing an in-app notification center with bell/badge UI, read/unread tracking, and REST API.

v1.0.0(1mo ago)11↑2900%1[1 PRs](https://github.com/jeremykenedy/laravel-notifications/pulls)MITBladePHP ^8.2|^8.3

Since Mar 29Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (7)Versions (3)Used By (0)

Laravel Notifications
=====================

[](#laravel-notifications)

A complete in-app notification center for Laravel with bell badge, unread count, mark-as-read, delete, real-time WebSocket broadcasting via Reverb, and a full REST API. Supports Tailwind CSS, Bootstrap 5, Bootstrap 4, with Blade, Livewire, Vue, React, and Svelte frontends.

[![Total Downloads](https://camo.githubusercontent.com/d3e410669a0e034f9f65894bbf1e3de309feeb61c45d43055b7a7513a106dccf/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f6c61726176656c2d6e6f74696669636174696f6e732f642f746f74616c2e737667)](https://packagist.org/packages/jeremykenedy/laravel-notifications)[![Latest Stable Version](https://camo.githubusercontent.com/143e98e31b95146cae830b64a5ad6b7f606c445e7a06f2ed8a3de0c67319fd4c/68747470733a2f2f706f7365722e707567782e6f72672f6a6572656d796b656e6564792f6c61726176656c2d6e6f74696669636174696f6e732f762f737461626c652e737667)](https://packagist.org/packages/jeremykenedy/laravel-notifications)[![StyleCI](https://camo.githubusercontent.com/e2235295a237640d7d89dbd1791dca80d5d81d19e05e2715136d208d67fb1141/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f313139343836323839382f736869656c643f6272616e63683d6d61696e)](https://github.styleci.io/repos/1194862898?branch=main)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

#### Table of Contents

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Notification Center Page](#notification-center-page)
    - [Bell Badge with Unread Count](#bell-badge-with-unread-count)
    - [Sending Notifications](#sending-notifications)
    - [Mark as Read](#mark-as-read)
    - [Delete Notifications](#delete-notifications)
- [CSS Framework Support](#css-framework-support)
    - [Tailwind CSS](#tailwind-css)
    - [Bootstrap 5](#bootstrap-5)
    - [Bootstrap 4](#bootstrap-4)
- [Frontend Framework Support](#frontend-framework-support)
    - [Blade with Alpine.js](#blade-with-alpinejs)
    - [Livewire](#livewire)
    - [Vue 3](#vue-3)
    - [React](#react)
    - [Svelte](#svelte)
- [Real-Time Broadcasting](#real-time-broadcasting)
- [Web Routes](#web-routes)
- [API Routes](#api-routes)
- [NotificationService API](#notificationservice-api)
- [Artisan Commands](#artisan-commands)
- [Testing](#testing)
- [License](#license)

Features
--------

[](#features)

FeatureFull notification center page with read/unread stylingNotification titles, messages, and action URLsType-based icons (welcome, new user, security, etc.)Bell icon with real-time unread count badgeMark individual or all notifications as readDelete individual or all notificationsReal-time push via Laravel Reverb WebSocketsFallback polling (configurable interval)`NotificationService` for programmatic access`BroadcastNotificationCreated` auto-listenerPaginated notification listMulti-CSS framework: Tailwind, Bootstrap 5, Bootstrap 4Multi-frontend: Blade/Alpine.js, Livewire 3, Vue 3, React, SvelteREST API with Sanctum authenticationArtisan install and switch commandsPublishable config, views, and translationsRequirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12 or 13
- A `notifications` database table (Laravel's built-in migration)

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

[](#installation)

```
composer require jeremykenedy/laravel-notifications
php artisan notifications:install --css=tailwind --frontend=blade
php artisan migrate
```

The install command publishes the config and views for your chosen CSS and frontend framework.

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

[](#configuration)

```
php artisan vendor:publish --tag=notifications-config
```

Key settings in `config/notifications.php`:

```
return [
    'enabled' => true,
    'per_page' => 20,
    'auto_mark_read_on_view' => false,
    'bell' => [
        'show_count' => true,
        'max_count_display' => 99,
        'poll_interval_ms' => 30000,
    ],
    'routes' => [
        'enabled' => true,
        'prefix' => 'notifications',
        'middleware' => ['web', 'auth'],
    ],
    'broadcast' => [
        'enabled' => true,
    ],
];
```

Usage
-----

[](#usage)

### Notification Center Page

[](#notification-center-page)

Navigate to `/notifications` to see all notifications. The page shows:

- Unread notifications with a blue left border
- Notification title and message
- Relative timestamps ("2 minutes ago")
- Action links when the notification includes a URL
- "Mark All Read" and "Delete All" buttons
- Pagination

### Bell Badge with Unread Count

[](#bell-badge-with-unread-count)

The bell icon in the nav bar shows the unread notification count. It:

- Fetches the count on page load via `GET /notifications/count`
- Polls every 30 seconds as fallback
- Updates instantly via WebSocket when Reverb is running
- Shows "99+" when count exceeds 99
- Hides completely when count is 0

### Sending Notifications

[](#sending-notifications)

Use Laravel's built-in notification system. Any notification sent via the `database` channel automatically appears in the notification center:

```
use App\Notifications\OrderShipped;

$user->notify(new OrderShipped($order));
```

The package automatically broadcasts a `NotificationCreated` event via WebSocket when any database notification is sent, so the bell badge updates in real-time.

### Mark as Read

[](#mark-as-read)

```
// Single notification
$user->notifications()->where('id', $id)->first()->markAsRead();

// All notifications
$user->unreadNotifications->markAsRead();

// Via service
app(NotificationService::class)->markAsRead($user, $notificationId);
app(NotificationService::class)->markAllAsRead($user);
```

### Delete Notifications

[](#delete-notifications)

```
app(NotificationService::class)->delete($user, $notificationId);
app(NotificationService::class)->deleteAll($user);
```

CSS Framework Support
---------------------

[](#css-framework-support)

The notification center view automatically renders with the correct CSS framework based on `config('ui-kit.css_framework')`.

### Tailwind CSS

[](#tailwind-css)

Pure Tailwind classes with `dark:` variants. No Bootstrap classes. Uses `` components.

### Bootstrap 5

[](#bootstrap-5)

Pure Bootstrap 5 classes (`list-group`, `badge`, `btn`, `d-flex`, `gap-*`). Uses `data-bs-dismiss` for alerts.

### Bootstrap 4

[](#bootstrap-4)

Pure Bootstrap 4 classes (`list-group`, `badge`, `btn`, `d-flex`). Uses `data-dismiss` for alerts and `mr-*` spacing instead of `me-*`.

Switch at any time:

```
php artisan notifications:switch --css=bootstrap5
```

Frontend Framework Support
--------------------------

[](#frontend-framework-support)

### Blade with Alpine.js

[](#blade-with-alpinejs)

The default. The notification center page uses `@extends('layouts.app')` with Alpine.js for interactivity (mark read, delete). No JavaScript frameworks needed.

```
{{-- Already available at /notifications --}}
```

### Livewire

[](#livewire)

A `NotificationsList` Livewire component with `wire:click` for all actions:

```

```

Methods: `markAsRead($id)`, `markAllAsRead()`, `delete($id)`. Supports pagination via `WithPagination`.

### Vue 3

[](#vue-3)

An Inertia.js page component:

```
php artisan notifications:install --frontend=vue
```

Publishes `NotificationsIndex.vue` to `resources/js/Pages/Notifications/`.

### React

[](#react)

```
php artisan notifications:install --frontend=react
```

Publishes `NotificationsIndex.jsx` to `resources/js/Pages/Notifications/`.

### Svelte

[](#svelte)

```
php artisan notifications:install --frontend=svelte
```

Publishes `NotificationsIndex.svelte` to `resources/js/Pages/Notifications/`.

Switch frontend at any time:

```
php artisan notifications:switch --frontend=vue
```

Real-Time Broadcasting
----------------------

[](#real-time-broadcasting)

When Laravel Reverb is configured (`BROADCAST_DRIVER=reverb`), the package automatically:

1. Listens for `NotificationSent` events (Laravel's built-in event)
2. Broadcasts a `NotificationCreated` event on `private-notifications.{userId}`
3. The nav bell badge subscribes via Echo and updates the count instantly

Channel authorization in `routes/channels.php`:

```
Broadcast::channel('notifications.{userId}', function ($user, $userId) {
    return (int) $user->id === (int) $userId;
});
```

Frontend subscription (automatic in the nav bar):

```
window.Echo.private('notifications.' + userId)
    .listen('.notification.created', (e) => {
        notifCount = e.count;
    });
```

Broadcasting can be disabled:

```
// config/notifications.php
'broadcast' => ['enabled' => false],
```

Web Routes
----------

[](#web-routes)

MethodURIDescription`GET``/notifications`Notification center page`GET``/notifications/count`Unread count as JSON `{"count": 5}``POST``/notifications/{id}/read`Mark single notification as read`POST``/notifications/read-all`Mark all notifications as read`DELETE``/notifications/{id}`Delete single notification`DELETE``/notifications`Delete all notificationsAll routes require `web` and `auth` middleware.

API Routes
----------

[](#api-routes)

MethodURIDescription`GET``/api/notifications`Paginated notifications (JSON)`GET``/api/notifications/unread`Unread notifications (JSON)`GET``/api/notifications/count`Unread count (JSON)`POST``/api/notifications/{id}/read`Mark as read`POST``/api/notifications/read-all`Mark all as read`DELETE``/api/notifications/{id}`Delete notificationAPI routes require `api` and `auth:sanctum` middleware.

NotificationService API
-----------------------

[](#notificationservice-api)

```
use Jeremykenedy\LaravelNotifications\Services\NotificationService;

$service = app(NotificationService::class);

$service->unreadCount($user);              // int
$service->getAll($user, $perPage);         // LengthAwarePaginator
$service->getUnread($user, $perPage);      // LengthAwarePaginator
$service->markAsRead($user, $id);          // void
$service->markAllAsRead($user);            // int (count marked)
$service->delete($user, $id);              // void
$service->deleteAll($user);                // void
```

Artisan Commands
----------------

[](#artisan-commands)

```
# Install with framework selection
php artisan notifications:install --css=tailwind --frontend=blade

# Switch CSS framework
php artisan notifications:switch --css=bootstrap5

# Switch frontend framework
php artisan notifications:switch --frontend=vue

# Switch both at once
php artisan notifications:switch --css=bootstrap4 --frontend=livewire

# Publish config only
php artisan vendor:publish --tag=notifications-config

# Publish views
php artisan vendor:publish --tag=notifications-views
```

Testing
-------

[](#testing)

The package includes comprehensive tests covering:

- **Service layer**: `unreadCount`, `getAll`, `getUnread`, `markAsRead`, `markAllAsRead`, `delete`, `deleteAll`
- **Web routes**: index, count, mark read, mark all read, delete, delete all
- **Authentication**: all routes require auth
- **CSS frameworks**: renders with Tailwind, Bootstrap 5, Bootstrap 4
- **Frontend frameworks**: renders with Blade, Livewire, Vue, React, Svelte
- **All 15 combinations**: every CSS x frontend combination tested
- **Livewire component**: render, markAsRead, markAllAsRead, delete, cross-CSS
- **Broadcasting**: NotificationCreated event channel, broadcast name, properties
- **Structural**: all view directories and JS component files verified

Run tests:

```
php artisan test --filter=NotificationsPackageTest
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05cef7d9ee65723b129042943511207fb34db74a56afbf67b5900987f758c161?d=identicon)[jeremykenedy](/maintainers/jeremykenedy)

---

Top Contributors

[![jeremykenedy](https://avatars.githubusercontent.com/u/6244570?v=4)](https://github.com/jeremykenedy "jeremykenedy (3 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

laravelnotificationsbadgein appcenterbell

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[laravel/cashier

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

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

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)

PHPackages © 2026

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