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

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

nht/notification
================

This Laravel package provides a simple, unified way to send notifications across multiple channels— Email, SMS, and Push Notifications—with minimal setup. Designed for developers who value efficiency and flexibility, it streamlines the process of reaching users wherever they are.

v3.0.2(2mo ago)0298MITBladePHP ^8.1

Since Nov 5Pushed 2mo agoCompare

[ Source](https://github.com/nazmulhasan1010/nht-notification)[ Packagist](https://packagist.org/packages/nht/notification)[ RSS](/packages/nht-notification/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (31)Used By (0)

NH Notification Package
=======================

[](#nh-notification-package)

**Version:** 2.2.0
**Author:** [Nazmul Hasan](mailto:nazmulhasan169369@gmail.com)
**License:** MIT
**Framework:** Laravel 10 / 11
**PHP:** &gt;= 8.1

---

🧩 Overview
----------

[](#-overview)

A modern Laravel package for sending **SMS**, **Email**, and **Push** notifications seamlessly across your application.
Easily queue and localize notifications with one unified interface.

---

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

[](#️-installation)

### 🪄 Step 1: Install Package

[](#-step-1-install-package)

```
composer require nht/notification
```

### ⚙️ Step 2: Enable Queues

[](#️-step-2-enable-queues)

Edit your `.env` file:

```
QUEUE_CONNECTION=database
```

Then create queue tables:

```
php artisan queue:table
php artisan queue:failed-table
php artisan migrate
```

### ⚡ Step 3: Publish Configurations

[](#-step-3-publish-configurations)

```
php artisan nht-notification:published
```

---

🧠 Import Class
--------------

[](#-import-class)

```
use NH\Notification\Notifications\Notification;
```

You can now send **SMS**, **Email**, or **Push** notifications — separately or together.

---

📱 SMS Notifications
-------------------

[](#-sms-notifications)

### ✉️ Option 1 — Using `Notification::send()`

[](#️-option-1--using-notificationsend)

```
Notification::send([
    'sms' => [
        'phone' => '+60135871622',
        // 'sms_to_users' => $users, // Optional: send to a specific user
        'message' => 'Write message here...',
    ],
]);
```

### 💬 Option 2 — Using `Notification::sendSms()`

[](#-option-2--using-notificationsendsms)

```
Notification::sendSms([
    'phone' => '+18777804236',
    'message' => 'Write message here...',
]);
```

---

📧 Email Notifications
---------------------

[](#-email-notifications)

```
$users = \App\Models\User::all();
```

### 🧰 Option 1 — Template Email

[](#-option-1--template-email)

To define the base view path, add to your `.env` file:

```
MAIL_TEMPLATE_PATH=emails
```

```
Notification::sendMailWithTemplate([
    'template' => ['withdrawal notification', 'Subject'], // ['view', 'subject key']
    'subject' => 'Withdrawal Request',
    'mail_to_users' => $users,
    'data' => [
        'user_name' => 'Anik Da',
        'amount' => 1000,
        'submitted_by' => 'Lukmanul Hakim Hasibuan',
        'status' => 'Pending',
        'transaction_view_on' => route('customer.product'),
    ],
]);
```

### 📩 Option 2 — Registration Notification

[](#-option-2--registration-notification)

```
Notification::send([
    'mail-template' => [
        'template' => ['registration', 'Subject'],
        'subject' => 'Welcome to ALJ Harmony',
        'mail_to' => 'email@email.com', // or ['email1', 'email2']
        'mail_to_users' => $users,
        'data' => (object)[
            'user_name' => 'Anik Da',
            'role' => 'Agency Admin',
            'agency_name' => 'ALJ Harmony',
            'email' => 'example@email.com',
            'login_on' => route('customer.product'),
        ],
    ]
]);
```

### 🛠️ Option 3 — Custom Email View

[](#️-option-3--custom-email-view)

```
Notification::send([
    'mail' => [
        'mail_to' => 'email@email.com',
        'mail_to_users' => $users,
        'subject' => 'Email Subject',
        'view' => 'applications.agents.emails.withdrawal-notification',
        'data' => (object)[
            'user_name' => 'Anik Da',
            'amount' => 1000,
            'submitted_by' => 'Lukmanul Hakim Hasibuan',
            'status' => 'Pending',
            'transaction_view_on' => route('customer.product'),
        ],
    ]
]);
```

### ✨ Option 4 — Using `sendMail()` Helper

[](#-option-4--using-sendmail-helper)

```
Notification::sendMail([
    'mail_to' => 'email@email.com',
    'mail_to_users' => $users,
    'subject' => 'Withdrawal Notification',
    'view' => 'applications.agents.emails.withdrawal-notification',
    'data' => (object)[
        'user_name' => 'Anik Da',
        'amount' => 1000,
        'submitted_by' => 'Lukmanul Hakim Hasibuan',
        'status' => 'Pending',
        'transaction_view_on' => route('customer.product'),
    ],
]);
```

---

🔔 Push Notifications
--------------------

[](#-push-notifications)

### 🗄️ Step 1: Setup Database

[](#️-step-1-setup-database)

```
php artisan notifications:table
php artisan migrate
```

### 🚀 Option 1 — Using `Notification::send()`

[](#-option-1--using-notificationsend)

```
Notification::send([
    'push' => [
        'sent_to_users' => $users,
        'data' => [
            'booking_id' => 1,
            'message' => 'Your booking has been confirmed.',
        ],
    ]
]);
```

### 🚀 Option 2 — Using `Notification::sendPush()`

[](#-option-2--using-notificationsendpush)

```
Notification::sendPush([
    'sent_to_users' => $users,
    'data' => [
        'booking_id' => 1,
        'message' => 'Your booking has been confirmed.',
    ],
]);
```

Push Notification Drawer
------------------------

[](#push-notification-drawer)

### 1. Overview

[](#1-overview)

The **Push Notification Drawer** is a slide-in panel that shows all recent notifications for the logged-in user.

- Opens from the **right side** of the screen.
- Can be toggled from the **notification bell icon** in the top bar.
- Shows **unread** and **read** notifications, grouped by time.
- Supports **click actions** (e.g., open related page, mark as read, etc.).

---

### 2. Demo Page URL

[](#2-demo-page-url)

You can view the demo page here:

👉 **URL:**
(Replace this with your actual domain name)

Example placeholder:

### Header menu bell icon

[](#header-menu-bell-icon)

[![Header menu bell icon](header-menu-bell-icon.png)](header-menu-bell-icon.png)

### Sidebar notification drawer

[](#sidebar-notification-drawer)

[![Sidebar notification drawer](sidebar-drawer.png)](sidebar-drawer.png)

### 2.1 Closed State (Bell Icon with Badge)

[](#21-closed-state-bell-icon-with-badge)

```
Top Navigation Bar
┌─────────────────────────────────────────────────────────┐
│  Logo         ...                         🔔 (3)       │
└─────────────────────────────────────────────────────────┘

```

---

🌍 Localization Support
----------------------

[](#-localization-support)

Enable localized messages in `.env`:

```
MAIL_SUBJECT_LOCALIZE=true
```

Create translation files:

```
resources/lang/en/notification.php
resources/lang/en/account_registration.php
```

Example:

```
Notification::send([
    'mail-template' => [
        'template' => ['registration', 'Subject'],
        ...
    ]
]);

return [
    'registration' => 'Hello :cun, your account at :agn is ready. Login here: :url',
];
```

---

📨 Retrieve Notifications
------------------------

[](#-retrieve-notifications)

```
Notification::get();
```

---

📡 API Reference
---------------

[](#-api-reference)

The package provides a JSON API for retrieving and managing notifications. These routes are protected by the `auth:sanctum` middleware and use the prefix `/api/v1` (configurable in `notification.php`).

### 1. Notifications List

[](#1-notifications-list)

Retrieve a list of notifications for the authenticated user.

- **Endpoint**: `GET /api/v1/notifications/{date?}`
- **URL Parameters**:
    - `date` (optional): Filter notifications by a specific date (e.g., `2025-05-01`).
- **Query Parameters**:
    - `guard` (optional): Specify an authentication guard.
- **Response**:

```
{
  "result": 1,
  "response": "Notifications list.",
  "notifications": {
    "all": [...],
    "unread": [...]
  }
}
```

### 2. Notification Statistics

[](#2-notification-statistics)

Get counts and periodic statistics for notifications.

- **Endpoint**: `GET /api/v1/notification-statistics`
- **Query Parameters**:
    - `guard` (optional): Specify an authentication guard.
- **Response**:

```
{
  "result": 1,
  "response": "Notifications statistics.",
  "data": {
    "total_notifications": 45,
    "unread_notifications": 12,
    "read_notifications": 33,
    "notifications_today": 5,
    "notifications_this_week": 20,
    "notifications_this_month": 45
  }
}
```

### 3. Mark as Read

[](#3-mark-as-read)

Mark a single notification or all notifications as read.

- **Endpoint**: `PUT /api/v1/notification/read/{item}`
- **URL Parameters**:
    - `item`: The UUID of the notification or `all` to mark all as read.
- **Query Parameters**:
    - `guard` (optional): Specify an authentication guard.
- **Response**:

```
{
  "result": 1,
  "response": 1,
  "unread": 11
}
```

### 4. Delete Notification

[](#4-delete-notification)

Delete a single notification or the last batch of notifications.

- **Endpoint**: `DELETE /api/v1/notification/delete/{item}`
- **URL Parameters**:
    - `item`: The UUID of the notification or `all` to delete the latest notifications.
- **Query Parameters**:
    - `guard` (optional): Specify an authentication guard.
- **Response**:

```
{
  "result": 1,
  "response": 1,
  "unread": 11
}
```

---

🧹 Uninstall Package
-------------------

[](#-uninstall-package)

To completely remove:

```
php artisan nht-notification:remove
// or
php artisan nht-notification:remove --force
```

and then

```
composer remove nht/notification
```

---

💡 Tips &amp; Notes
------------------

[](#-tips--notes)

- Ensure queue worker is running: ```
    php artisan queue:work
    ```
- `mail_to_users` accepts any `User` model collection.
- `phone` must follow **E.164** international format (`+60`, `+88`, etc.).
- You can combine SMS + Email + Push in a single call.
- Works perfectly with **queued notifications**.

---

🧬 Example: Combined Notification
--------------------------------

[](#-example-combined-notification)

```
Notification::send([
    'sms' => [
        'phone' => '+60135871622',
        'message' => 'Account activated successfully.',
    ],
    'mail' => [
        'mail_to' => 'email@email.com',
        'subject' => 'Account Activated',
        'view' => 'emails.account-activated',
        'data' => (object)['user_name' => 'Lukmanul Hakim'],
    ],
    'push' => [
        'sent_to_users' => $users,
        'data' => [
            'title' => 'Welcome!',
            'message' => 'Your account is ready to use.',
        ],
    ],
]);
```

---

🛠️ Troubleshooting
------------------

[](#️-troubleshooting)

⚠️ Issue💡 FixEmail not sendingCheck `.env` mail configuration and queue connectionSMS not sendingVerify your SMS API credentials and gateway setupPush not workingEnsure `notifications` table exists &amp; `Notifiable` trait is used in `User` model`route('login')` undefinedEnsure your `web.php` defines a named route for login---

🧭 License
---------

[](#-license)

Released under the **MIT License**.
© 2025 [Nazmul Hasan](mailto:nazmulhasan169369@gmail.com)

---

🧡 Built with passion for modern Laravel development.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance87

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~6 days

Total

29

Last Release

63d ago

Major Versions

v1.9.0 → v2.0.02026-01-14

v2.9.0 → v3.0.02026-04-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/acf7a80b5081927b27fbec110a59bb120656e088424abc1bab0324cc05e0bfca?d=identicon)[nazmulhasan](/maintainers/nazmulhasan)

---

Top Contributors

[![nazmulhasan1010](https://avatars.githubusercontent.com/u/70843973?v=4)](https://github.com/nazmulhasan1010 "nazmulhasan1010 (30 commits)")

---

Tags

laravelpackageemailnotificationsmspush notificationBroadcast

### Embed Badge

![Health badge](/badges/nht-notification/health.svg)

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

###  Alternatives

[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2588.4M17](/packages/laravel-notification-channels-twilio)[gr8shivam/laravel-sms-api

A modern, flexible Laravel package for integrating any SMS gateway with REST API support

10240.6k](/packages/gr8shivam-laravel-sms-api)[ghanem/laravel-smsmisr

Send SMS and SMS Notification via SMS Misr for Laravel

205.0k](/packages/ghanem-laravel-smsmisr)

PHPackages © 2026

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