Support tickets
Both halves of a help desk. Signed-in users open tickets and follow the conversation at /support; admins answer from a queue at /admin/support; each side is mailed when the other writes.


What it adds
| File | Purpose |
|---|---|
app/Models/SupportTicket.php, app/Models/TicketReply.php | Models with a ulid per ticket, open() scope, replies relation, categories() and the badge tone methods |
database/factories/SupportTicketFactory.php, TicketReplyFactory.php | Factories, with closed() and fromAdmin() states |
database/migrations/*_create_support_tickets_table.php, *_create_ticket_replies_table.php | support_tickets with subject, category, priority, status, IP and closed timestamp; ticket_replies with an is_admin_reply flag |
app/Livewire/Support/TicketList.php, CreateTicket.php, TicketDetail.php and their views | The user's pages, in the user shell |
app/Livewire/Admin/Support/TicketList.php, TicketDetail.php and their views | The admin queue and thread |
app/Policies/SupportTicketPolicy.php | Who may view, update and delete a ticket |
app/Mail/NewTicketMail.php, TicketReplyMail.php, TicketStatusChangedMail.php, resources/views/mail/support/* | The three mailables and their markdown views |
Install
php artisan ui-kit:install-module support-tickets
No Composer packages. Mail goes through your queue, so run php artisan queue:work unless QUEUE_CONNECTION=sync, and set MAIL_FROM_ADDRESS.
What the installer changes
- Adds three routes between the user-routes markers in
routes/ui-kit-user.php(signed-in users) and two between the markers inroutes/admin.php. - Adds a
Supportentry with theopen_ticketsbadge between the nav markers inconfig/admin.php. The kit's default badge resolver counts open tickets, so the badge works with no code; see Customising to replace it. - Runs the two migrations.
Routes
| Route | Name | Component |
|---|---|---|
GET /support | support.index | Support\TicketList: the user's own tickets, a status filter |
GET /support/create | support.create | Support\CreateTicket: subject, category, message |
GET /support/{ulid} | support.show | Support\TicketDetail: the conversation, a reply, Close and Reopen |
GET /admin/support | admin.support.index | Admin\Support\TicketList: stat tiles, search, status, priority and category filters |
GET /admin/support/{ulid} | admin.support.show | Admin\Support\TicketDetail: the thread, inline reply, status and priority changes |
The /support paths are yours to rename in routes/ui-kit-user.php; keep the route names, which the shell's Support link and the mail use.
The user's side
/support lists the signed-in user's own tickets, newest first and 15 to a page: subject with category and message count, a status badge and a priority badge (colours from SupportTicket::statusTone() and priorityTone(), the same as the admin side), when it last changed, and a View button. A status select filters the list and keeps the choice in the query string (/support?status=closed). With no tickets yet, an empty state offers New ticket.


The form takes a subject (up to 255 characters), a category from SupportTicket::categories() and a message of 20 to 5,000 characters. It opens the ticket with priority medium and status open, saves the user's IP, makes the message the ticket's first reply, mails the admins, and goes to the new ticket. A user may open five tickets an hour; a submit that fails validation does not count. A hidden honeypot field catches form-filling bots: one that fills it is sent to the list as if it had worked, and nothing is saved.


A ticket shows its category, when it was opened and its status, then the conversation, then a reply box (2 to 5,000 characters, ten replies an hour per ticket). Close ticket and Reopen ticket sit beside the status. A closed or resolved ticket takes no replies; the page says to reopen it first.
Who may see what
App\Policies\SupportTicketPolicy is published to app/Policies, where Laravel finds it by name, so nothing registers it. The ticket's owner or an admin (UiKit::isAdmin(): the Spatie admin role or is_admin) may view and update a ticket; only an admin may delete one. Anyone else gets a 403 from /support/{ulid}. The doctor's support ticket policy published row fails if the file is missing, because every ticket page would answer 403.
The admin's side


The queue opens with four stat tiles: total, open, in progress and resolved. Under them, a search field (subject, name or email) and status, priority and category selects filter a table with the columns Subject (with the reply count), From, Status, Priority, Category and Updated, and a View button per row. Pages change through Livewire without losing the filters.
A ticket shows who sent it, when, its category and IP address; beside that, one panel holds the Status and Priority selects, saved as soon as they change. Under it, the conversation and a reply form.


| Mailable | Sent when | To |
|---|---|---|
NewTicketMail | A user opens a ticket | The admins; replying to it writes to the user. The button opens the admin page. |
TicketReplyMail | A user replies | The admins, with the admin link (toAdmin: true) |
TicketReplyMail | An admin replies | The ticket's owner, with the link to their own ticket page |
TicketStatusChangedMail | An admin changes the status | The ticket's owner, with the old and new status; a closing one says how to reopen |
"The admins" are UiKit::admins(): the users with the admin role, or with is_admin when admin-middleware is not installed. Set UI_KIT_ADMIN_ADDRESSES to send to a shared mailbox instead (Customising). Every mail is sent after the ticket or reply is saved, and a send that fails is logged, so a mail server that is down never loses a ticket; the admin screen then says "Reply saved, but the email failed: …". The doctor's support-tickets mail views published row checks every class and view. Troubleshooting covers mail that never arrives.
With contacts
The contacts module adds a Copy to Ticket button to its inbox when both are installed.
Removing
Delete the models, factories, policy, mailables and mail views, both sets of Livewire components and views, remove the route lines from routes/ui-kit-user.php and routes/admin.php and the nav entry between their markers, drop the two tables, and remove support-tickets from installed_modules in config/ui-kit.php.