1. Overview

WHMS has a unified notification system that delivers notifications through three channels: database (in-app bell icon), email, and SMS. The NotificationService orchestrates all three channels from a single call point. Admin users see notifications in the top header bar with real-time polling (every 30 seconds).

2. Architecture

ComponentLocationPurpose
NotificationServiceapp/Services/NotificationService.phpCentral orchestrator for all notification channels
GeneralNotificationapp/Notifications/GeneralNotification.phpLaravel notification class for database channel
NotificationControllerapp/Http/Controllers/Admin/NotificationController.phpAdmin endpoints: list, mark read, recent (JSON)
Notifications TableLaravel default (UUID-based)Stores notifications with type, data JSON, read_at

3. Notification Channels

ChannelDeliveryDescription
Database Instant Stored in notifications table. Appears in admin header bell icon with unread count. Sent to the client user AND all admin users.
Email Instant Sent via configured mail driver using the matching EmailTemplate. Only sent if the template exists and is active.
SMS Instant Sent via configured SMS provider. Only sent if notification.sms_enabled is true AND user has a phone number.

4. Notification Data Structure

Each database notification stores a JSON data object with these fields:

FieldTypeDescription
titlestringNotification title (e.g. "New Invoice Generated")
messagestringNotification body text
iconstringFont Awesome icon class (default: "fa-bell")
colorstringBootstrap color class (default: "info")
urlstringLink to relevant page (default: "#")
invoice_idint (optional)Related invoice ID
invoice_numberstring (optional)Related invoice number

5. Event-Driven Notifications

Notifications are triggered automatically by invoice lifecycle events:

EventListenerDB TitleEmail Template
InvoiceCreated NotifyInvoiceCreated "New Invoice Generated" invoice-created
InvoicePaid NotifyInvoicePaid "Invoice Paid" invoice-paid
InvoiceOverdue NotifyInvoiceOverdue "Invoice Overdue" invoice-overdue
Scheduled SendInvoiceReminder "Invoice Payment Reminder" invoice-reminder / invoice-overdue-reminder

6. NotificationService Flow

When an invoice event occurs, the NotificationService executes these steps in order:

7. Admin Notification Endpoints

RouteMethodDescription
/admin/notificationsGETPaginated list of all notifications (25 per page)
/admin/notifications/recentGETJSON endpoint returning 10 latest unread notifications (polled every 30s)
/admin/notifications/{id}/readPOSTMark a single notification as read
/admin/notifications/mark-all-readPOSTMark all unread notifications as read

8. Complete Event Listener Map

EventListenerAction
InvoiceCreatedNotifyInvoiceCreatedDB notification + Email + SMS
InvoicePaidNotifyInvoicePaidDB notification + Email + SMS
InvoicePaidProvisionServicesOnPaymentDispatches provisioning jobs for order items
InvoicePaidUpdateServiceDueDatesOnRenewalPaymentExtends domain/hosting expiry for renewal invoices
InvoiceOverdueNotifyInvoiceOverdueDB notification + Email + SMS
OrderPlacedCreateInitialInvoiceCreates initial invoice from order
MessageSent (Mail)LogSentEmailLogs all sent emails to ActivityLog