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.

A user's own tickets: a New ticket button, a status filter and a table of tickets with status and priority badges
/support: a user's own tickets.

What it adds

FilePurpose
app/Models/SupportTicket.php, app/Models/TicketReply.phpModels with a ulid per ticket, open() scope, replies relation, categories() and the badge tone methods
database/factories/SupportTicketFactory.php, TicketReplyFactory.phpFactories, with closed() and fromAdmin() states
database/migrations/*_create_support_tickets_table.php, *_create_ticket_replies_table.phpsupport_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 viewsThe user's pages, in the user shell
app/Livewire/Admin/Support/TicketList.php, TicketDetail.php and their viewsThe admin queue and thread
app/Policies/SupportTicketPolicy.phpWho 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 in routes/admin.php.
  • Adds a Support entry with the open_tickets badge between the nav markers in config/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

RouteNameComponent
GET /supportsupport.indexSupport\TicketList: the user's own tickets, a status filter
GET /support/createsupport.createSupport\CreateTicket: subject, category, message
GET /support/{ulid}support.showSupport\TicketDetail: the conversation, a reply, Close and Reopen
GET /admin/supportadmin.support.indexAdmin\Support\TicketList: stat tiles, search, status, priority and category filters
GET /admin/support/{ulid}admin.support.showAdmin\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 new ticket form: subject, a category select and a message box with a hint, and the Open ticket button
/support/create.

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.

One ticket from the user's side: its status badge and a Close ticket button, the conversation with a Support team badge on the admin's reply, and a reply box
/support/{ulid}. Admin replies carry a Support team badge.

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 support ticket queue: four stat tiles, a search field and three filters over a table of tickets with status and priority badges
/admin/support: counts by status, then the queue as a table.

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.

A single ticket: sender details, the status and priority panel, the conversation and the reply form
A ticket in the admin panel.

Mail

MailableSent whenTo
NewTicketMailA user opens a ticketThe admins; replying to it writes to the user. The button opens the admin page.
TicketReplyMailA user repliesThe admins, with the admin link (toAdmin: true)
TicketReplyMailAn admin repliesThe ticket's owner, with the link to their own ticket page
TicketStatusChangedMailAn admin changes the statusThe 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.

Was this page helpful?