Overview
TheRecordDetails component displays detailed information about a specific health record (appointment, exercise, weight measurement, or heart rate measurement) in a modal window. It handles loading records dynamically based on their type and allows downloading associated attachments.
Namespace: App\Livewire\Dashboard\RecordDetails
Properties
The loaded record instance (MedicalAppointment, ActivityExercise, MeasurementWeight, or MeasurementHeart)
The type of record:
'MedicalAppointment', 'ActivityExercise', 'MeasurementWeight', or 'MeasurementHeart'Whether the modal is currently open (unused in current implementation)
Event Listeners
Triggers
loadRecord($id, $type) when a record is clicked from the calendarapp/Livewire/Dashboard/RecordDetails.php:19
Methods
loadRecord()
Loads a record by ID and type, then opens the details modal.app/Livewire/Dashboard/RecordDetails.php:21-39
The ID of the record to load
One of:
MedicalAppointment, ActivityExercise, MeasurementWeight, MeasurementHeartuser_id = auth()->id() to ensure users can only view their own records.
Modal Dispatch: Opens the 'record-details' modal using Livewire’s modal system.
downloadFile()
Downloads an attachment file associated with the record.app/Livewire/Dashboard/RecordDetails.php:41-48
The ID of the attachment to download
user_id = auth()->id().
Storage: Files are stored in the local disk (typically storage/app/).
Usage Example
The component is included in the dashboard layout and listens forview-record events:
Record Type Matching
The component uses PHP 8’smatch() expression to map string type names to model classes:
| Type String | Model Class |
|---|---|
MedicalAppointment | App\Models\MedicalAppointment |
ActivityExercise | App\Models\ActivityExercise |
MeasurementWeight | App\Models\MeasurementWeight |
MeasurementHeart | App\Models\MeasurementHeart |
Modal Structure
The modal displays different information based on record type: Appointments & Exercise:- Title
- Date
- Description
- List of attachments with download buttons
- Date
- Measurement values
- Optional description (for weight)
Dependencies
- Storage Facade - For file downloads
- Attachment Model - For file metadata
- All health record models - For loading records
- Livewire Modal System - For displaying the modal
Security Considerations
Related Components
Calendar Component
Dispatches view-record events when days are clicked
Attachment Controller
Alternative attachment viewing method
