The notifications module (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Nieto2020/portalhub/llms.txt
Use this file to discover all available pages before exploring further.
modules/notificaciones/) provides a lightweight in-app notification inbox for every user. Notifications are created in two ways: automatically by NotificationService when platform events occur (new appointments, uploaded documents, payment updates), and manually by admins or advisors through the dedicated endpoints. All notifications are stored in the notificaciones table and are only ever visible to their designated recipient.
Notification Record Fields
| Column | Type | Description |
|---|---|---|
id_notificacion | int | Auto-increment primary key |
id_usuario_destino | int (FK) | The user who will see the notification |
tipo_evento | string | Free-form event category (e.g. "Cita", "Documento", "Pago", "sistema") |
mensaje_texto | string | Human-readable notification message |
leida | bool | false by default; set to true when the user reads it |
fecha_creacion | datetime | Timestamp of insertion |
NotificationService
NotificationService.php is a shared PHP class used by other backend modules to fire notifications without repeating database logic. Any module that needs to alert a user simply instantiates the service and calls notify():
When Notifications Are Auto-Created
NotificationService::notify() is called automatically in the following scenarios:
New Appointment
When
citas/crear.php saves a new appointment, the assigned advisor receives a "Cita" notification: “Se ha programado una nueva cita para el: ”.Document Uploaded by Client
When a client uploads a document via
documentos/subir.php, their active advisor receives a "Documento" notification with the original filename.Document Uploaded by Advisor/Admin
When an advisor or admin uploads a document to a client’s record, the client receives a
"Documento" notification.Payment Updates
Payment status changes can trigger a
"Pago" notification to the affected client when integrated with pagos/actualizar_estado.php.Creating a Single Notification (Manual)
Endpoint:POST modules/notificaciones/crear.php
Restricted to ROL_ADMIN and ROL_ASESOR. Allows staff to push a targeted notification to any specific user.
Required fields:
| Field | Type | Description |
|---|---|---|
id_usuario_destino | int | Recipient user ID |
tipo_evento | string | Event category label |
mensaje_texto | string | Notification message body |
- Request
- Success Response (201)
- Missing Fields (400)
Bulk Broadcast Notifications (Admin Only)
Endpoint:POST modules/notificaciones/crear_masivo.php
Only ROL_ADMIN may call this endpoint. It creates an identical notification for every user matching the specified role list inside a single database transaction. The tipo_evento is automatically set to 'sistema' for all bulk notifications.
Required fields:
| Field | Type | Description |
|---|---|---|
titulo | string | Short title prepended to the message |
contenido | string | Body of the notification |
| Field | Type | Description |
|---|---|---|
roles | int[] | Target role IDs (default: [1, 2, 3] — all roles) |
mensaje_texto is formatted as:
- Request
- Success Response (200)
All inserts in
crear_masivo.php are wrapped in a transaction. If any insertion fails, rollBack() is called and no partial notifications are persisted.Listing Notifications
Endpoint:GET modules/notificaciones/listar.php
Returns all notifications addressed to the logged-in user (id_usuario_destino = id_usuario), ordered by fecha_creacion DESC. This endpoint powers the portal’s notification bell/inbox.
Response item shape:
Marking Notifications as Read
Endpoint:POST modules/notificaciones/marcar_leido.php
Accepts an id_notificacion and sets leida = 1 for the matching record. The endpoint verifies ownership (the notification’s id_usuario_destino must match the session user) to prevent users from marking each other’s notifications read.