Skip to main content

Support

Responsible for customer support tickets. A signed-in customer opens a ticket — optionally tied to one of their orders by order_code — and the thread alternates between customer and staff messages until the ticket is closed. The storefront exposes it under the account area (/profile/tickets); the admin panel manages it under Support → Tickets.

Tables​

TableDescription
support_ticketsTickets (subject, status, optional order_code link, last_message_at)
support_ticket_messagesThread messages (sender is customer or admin)

Statuses​

StatusMeaning
openCreated, or reopened by a new customer reply
answeredAn admin replied — the last word is staff's
closedClosed by the customer or by an admin

An admin reply moves the ticket to answered; a customer reply forces it back to open (reopening closed tickets). Customers may only set open/closed on their own tickets; admins may set any status.

Endpoints​

All endpoints require Sanctum authentication. Customer endpoints are ownership-scoped (a global query scope hides other customers' tickets); admin endpoints require per-route permissions (support.admin.*).

EndpointAudiencePurpose
GET /support/user/ticketsUserList own tickets (filter by status)
POST /support/user/ticketsUserCreate a ticket (subject, body, optional order_code)
GET /support/user/tickets/{id}UserShow a ticket with its message thread
PATCH /support/user/tickets/{id}/statusUserOpen/close an own ticket
POST /support/user/tickets/{id}/messagesUserReply
GET /support/admin/ticketsAdminList tickets (filters: status, user_id, subject, order_code)
GET /support/admin/tickets/{id}AdminShow with messages — authors resolved to name/email
PATCH /support/admin/tickets/{id}/statusAdminSet any status
POST /support/admin/tickets/{id}/messagesAdminReply as staff
DELETE /support/admin/tickets/{id}AdminDelete a ticket

Ticket creation validates that a given order_code belongs to the customer. Payload limits: subject ≤ 255 chars, message body ≤ 5000. Creation and replies are rate limited per user (10/min and 30/min by default).

Events emitted​

EventWhen
TicketCreatedEventA ticket is created
TicketMessageCreatedEventA customer or admin reply lands
TicketStatusUpdatedEventA ticket's status changes
TicketDeletedEventA ticket is deleted by an admin

The Notification module listens to these: staff receive database + email notifications on new tickets and customer replies; the customer is notified (database + email + web push) when staff answer. Admin notifications carry ticket_id in their meta, which the admin panel's bell uses to deep-link straight to the ticket.

Dependencies​

ModuleReason
CoreEvent contracts, user/order access gateways