This repository contains the backend API for the Customer Support System, built with Laravel. The API powers ticket creation, assignment, comments, attachments, and real-time notifications (Pusher + Laravel Broadcasting).
This README documents implemented features, setup instructions, important environment variables, and how to test the real-time notification flow.
- Authentication with Laravel Sanctum (register/login/logout).
- Ticket lifecycle: create, view, update, delete.
- Ticket assignment to admin users with database notifications and broadcast events.
- Comments and attachments on tickets.
- Persistent notifications stored in the
notificationstable and real-time delivery via Pusher. - Broadcasting channels:
admin-notifications(admins)user.{id}(private per-user channel)
- Events implemented:
TicketCreated,TicketAssigned,TicketUpdated,TicketDeleted. - Admin-only endpoints: customers, tickets, recent tickets (latest 10), admins list for assignment.
Prerequisites:
- PHP 8.2+
- Composer
- MySQL
- Node.js & npm (front-end client)
- Install dependencies
composer install- Environment
Copy .env.example to .env and configure values. Important environment variables:
- APP_URL (e.g.
http://127.0.0.1:8000) - DB_CONNECTION (sqlite/mysql)
- PUSHER_APP_ID
- PUSHER_APP_KEY
- PUSHER_APP_SECRET
- PUSHER_APP_CLUSTER
- BROADCAST_CONNECTION=pusher
- Database
If you use SQLite, point DB_CONNECTION=sqlite and create database/database.sqlite.
Run migrations and seeders:
php artisan migrate --seed- Run the application
php artisan serve- Start a queue worker (recommended for queued broadcasts/events)
php artisan queue:workThis project uses Laravel broadcasting with the Pusher driver. Make sure your .env contains the correct Pusher credentials and BROADCAST_CONNECTION=pusher.
Frontend clients must authenticate private channels by sending the Bearer token to the Laravel broadcasting auth endpoint (the client is already configured to use api/broadcasting/auth).
Authentication
POST /api/register— register a new user (returns token)POST /api/login— login (returns token)POST /api/logout— logout (requires auth)
Tickets
GET /api/tickets— list tickets (admins see all, customers see own)POST /api/tickets— create ticket (auth)GET /api/tickets/{ticket}— show ticketPUT/PATCH /api/tickets/{ticket}— update ticket (admin)DELETE /api/tickets/{ticket}— delete ticket (admin)POST /api/tickets/{ticket}/assign— assign ticket to admin (admin only)
Admin routes (prefix /api/admin)
GET /api/admin/customers— get customers listGET /api/admin/tickets— list all ticketsGET /api/admin/recent-tickets— get latest 10 ticketsGET /api/admin/admins— list admin users (for assignment dropdown)
Notifications
GET /api/notifications— user notificationsPATCH /api/notifications/{id}/read— mark a notification readPATCH /api/notifications/mark-all-read— mark all notifications readGET /api/notifications/unread-count— unread count
- Events (TicketCreated / TicketAssigned / TicketUpdated / TicketDeleted) create database notifications for relevant users.
- Events also implement
ShouldBroadcastand broadcast payloads on:admin-notificationschannel for adminsuser.{id}private channels for specific users
- Frontend connects to Pusher and authenticates through
/api/broadcasting/authusing the Bearer token. - When an event is broadcast, the front-end receives the payload and displays an in-app toast and the notification is persisted in the DB.
Important: Ensure php artisan queue:work is running if your events are queued.
Endpoint: POST /api/tickets/{ticket}/assign
Request body:
{ "assigned_to": 3 }Notes:
- Only admin users may call this endpoint.
- The assigned user must have
role = 'admin'. - The action creates notifications for the assigned admin and other admins, and broadcasts a
notification.ticket.assignedevent.
- 404 on new routes: clear and re-cache routes after changes:
php artisan route:clear && php artisan route:cache. - 403 broadcasting auth: ensure the frontend sends the Bearer token to
/api/broadcasting/authandBROADCAST_CONNECTIONispusher. - No real-time events: make sure the queue worker is running.
- Add integration tests for events and notification flow.
- Add Postman collection and API documentation.
- Add pagination and filtering to admin ticket endpoints.
If you want, I'll add a matching README for the frontend client that explains how to configure Pusher and the NotificationProvider usage.