In-App Notifications

In-app notifications are stored in the database and displayed to users in real time through the frontend notification dropdown.

GeneralNotification

The GeneralNotification class uses Laravel's database channel to persist notifications in the notifications table. Each notification stores:

  • type — the notification class name
  • data — JSON payload with title, message, and metadata
  • read_at — timestamp when the user marked it as read (null if unread)

Frontend Component

The NotificationsDropdown React component provides the in-app notification experience:

  • Bell icon in the header with an unread count badge
  • Dropdown panel listing recent notifications
  • Click to mark individual notifications as read
  • "Mark all as read" action
  • Polling for new notifications at a regular interval

API Endpoints

List Notifications

GET /api/notifications

Returns a paginated list of the authenticated user's notifications, ordered by most recent first.

Unread Count

GET /api/notifications/unread-count

Returns a count of unread notifications, used by the badge in the frontend:

{
    "unread_count": 3
}

Mark as Read

PATCH /api/notifications/{id}/read

Marks a single notification as read by setting read_at to the current timestamp.

Mark All as Read

POST /api/notifications/read-all

Marks all of the user's unread notifications as read.

Delete Notification

DELETE /api/notifications/{id}

Permanently removes a notification from the user's list.