Overview
The Calendar component provides an interactive monthly calendar view that displays health measurements, exercises, and medical appointments. Users can navigate between months and select individual days to view detailed information.Class Information
Namespace:App\Livewire\Dashboard
Class: Calendar
Traits: HasContext
Public Properties
| Property | Type | Description |
|---|---|---|
currentDate | Carbon | The currently displayed month/year |
selectedDate | Carbon|null | The selected date for viewing details |
dayDetails | array | Contains detailed data for the selected day |
Methods
mount()
Initializes the component with the current date.nextMonth()
Navigates to the next month in the calendar.prevMonth()
Navigates to the previous month in the calendar.goToCurrentMonth()
Resets the calendar to the current month.selectDay($dateString)
Selects a specific day and loads all related health data for that date. Parameters:$dateString(string) - Date in parseable format (e.g., ‘Y-m-d’)
hearts- Collection of MeasurementHeart recordsweights- Collection of MeasurementWeight recordsexercises- Collection of ActivityExercise records with attachmentsappointments- Collection of MedicalAppointment records with attachments
refresh()
Refreshes the calendar component. Called via event listener.Event Listeners
| Event | Method | Description |
|---|---|---|
refresh-calendar | refresh() | Refreshes the calendar display |
Event Dispatchers
| Event | Parameters | Description |
|---|---|---|
open-modal | 'day-details' | Opens the day details modal |
Render Data
Therender() method provides the following data to the view:
| Variable | Type | Description |
|---|---|---|
days | array | Array of day objects with metadata |
monthName | string | Formatted month and year (e.g., “January 2024”) |
nextAppointment | MedicalAppointment|null | Next upcoming appointment |
latestWeight | MeasurementWeight|null | Most recent weight measurement |
weightDiff | float | Difference between latest and previous weight |
weeklyMinutes | int | Total exercise minutes in the last 7 days |
weeklyActivitiesCount | int | Number of activities this week |
Day Object Structure
Each day in thedays array contains:
Component Usage
Basic Implementation
Blade Template Example
Dependencies
Carbon\Carbon- Date manipulationApp\Models\MeasurementHeart- Heart measurement modelApp\Models\MeasurementWeight- Weight measurement modelApp\Models\ActivityExercise- Exercise activity modelApp\Models\MedicalAppointment- Medical appointment modelApp\Traits\HasContext- Context trait for user targeting
