Authentication
All endpoints require:- Middleware:
auth,verified - Role:
admin,doctor, orreceptionist
Endpoints
List Appointments
Query Parameters
Filter appointments by doctor ID. Note: Doctors automatically see only their own appointments regardless of this parameter.
Filter appointments by date (format: YYYY-MM-DD)
Page number for pagination
Response
Returns an Inertia render with:Paginated collection of appointments
Array of appointment objects
Appointment ID
Patient ID
Patient information
Doctor (User) ID
Doctor information
Appointment start time
Appointment end time
Appointment status:
scheduled, confirmed, completed, cancelled, or no_showReason for appointment
Additional notes
Current page number
Items per page (20)
List of doctors for filtering (id and name)
Active filters (doctor_id, date)
Role-Based Filtering
- Doctors: Automatically filtered to show only their own appointments
- Admin/Receptionist: Can view all appointments or filter by doctor
Create Appointment Form
Query Parameters
Pre-select a patient for the appointment
Response
Returns an Inertia render with:List of all patients (id and full_name) sorted alphabetically
List of doctors (id and name)
Pre-selected patient ID from query parameter
Store Appointment
Request Body
Patient ID (must exist in patients table)
Doctor ID (must exist in users table)
Appointment start time (format: YYYY-MM-DD HH:MM:SS)
Appointment end time (must be after start_time)
Reason for appointment (max 255 characters)
Additional notes
Validation
patient_id: Must exist in patients tabledoctor_id: Must exist in users tablestart_time: Must be a valid dateend_time: Must be a valid date and afterstart_time
Response
Redirects back with success message: “Cita agendada correctamente.”Update Appointment
Path Parameters
Appointment ID
Request Body
All fields are optional:Appointment status. Must be one of:
scheduled, confirmed, completed, cancelled, no_showNew start time
New end time (must be after start_time if provided)
Updated notes
Status Values
scheduled: Initial state when appointment is createdconfirmed: Appointment confirmed by patient or staffcompleted: Appointment has been completedcancelled: Appointment cancelledno_show: Patient did not show up for appointment
Response
Redirects back with success message: “Cita actualizada.”Delete Appointment
Path Parameters
Appointment ID
Response
Redirects back with success message: “Cita eliminada.”Implementation Details
- Source:
app/Http/Controllers/AppointmentController.php - Route:
/appointments - Uses action classes:
CreateAppointmentAction,UpdateAppointmentAction - Pagination: 20 records per page
- Appointments sorted by
start_time(latest first) - Soft deletes enabled
- Relationships: Eager loads
patientanddoctorfor performance
Date/Time Handling
- All datetime fields are automatically cast to Carbon instances
- Dates should be provided in ISO 8601 format:
YYYY-MM-DD HH:MM:SS - Filtering by date uses
whereDate()for date-only comparison
Role-Specific Behavior
Doctor Role
- Automatically sees only their own appointments in the index
- Cannot filter by other doctors
Admin/Receptionist Roles
- Can view all appointments
- Can filter by any doctor
- Full CRUD access to all appointments