Overview
The Health Tracking components provide interfaces for logging and editing weight measurements and heart rate data. Both components support creating new records and editing existing ones.WeightLog Component
Class Information
Namespace:App\Livewire\Dashboard
Class: WeightLog
Public Properties
| Property | Type | Description |
|---|---|---|
weightId | int|null | ID of the weight record being edited (null for new records) |
weight | float | Weight value in kg |
date | string | Date and time of measurement (Y-m-d\TH:i format) |
description | string | Optional description (not used in validation) |
Methods
mount()
Initializes the component with the current date and time.editWeight($id)
Loads an existing weight record for editing. Parameters:$id(int) - The ID of the weight record to edit
save()
Validates and saves the weight record (creates new or updates existing).Validation Rules
| Field | Rules | Description |
|---|---|---|
weight | required, numeric, min:1, max:500 | Weight in kg (1-500) |
date | required, date | Date and time of measurement |
Event Listeners
| Event | Method | Description |
|---|---|---|
edit-weight-item | editWeight($id) | Opens the edit form for a weight record |
Event Dispatchers
| Event | Parameters | Triggered When |
|---|---|---|
open-modal | 'log-weight' | Opening the edit form |
close-modal | 'log-weight' | After successful save |
refresh-calendar | - | After successful save |
refresh-history | - | After successful save |
Component Usage
Blade Template Example
HeartLog Component
Class Information
Namespace:App\Livewire\Dashboard
Class: HeartLog
Public Properties
| Property | Type | Description |
|---|---|---|
heartId | int|null | ID of the heart record being edited (null for new records) |
systolic | int | Systolic blood pressure (upper number) |
diastolic | int | Diastolic blood pressure (lower number) |
bpm | int | Heart rate in beats per minute |
date | string | Date and time of measurement (Y-m-d\TH:i format) |
Methods
mount()
Initializes the component with the current date and time.editHeart($id)
Loads an existing heart measurement record for editing. Parameters:$id(int) - The ID of the heart record to edit
save()
Validates and saves the heart measurement record (creates new or updates existing).Validation Rules
| Field | Rules | Description |
|---|---|---|
systolic | required, integer, min:50, max:250 | Systolic pressure (50-250 mmHg) |
diastolic | required, integer, min:30, max:150 | Diastolic pressure (30-150 mmHg) |
bpm | required, integer, min:30, max:220 | Heart rate (30-220 BPM) |
date | required, date | Date and time of measurement |
Event Listeners
| Event | Method | Description |
|---|---|---|
edit-heart-item | editHeart($id) | Opens the edit form for a heart record |
Event Dispatchers
| Event | Parameters | Triggered When |
|---|---|---|
open-modal | 'log-heart' | Opening the edit form |
close-modal | 'log-heart' | After successful save |
refresh-calendar | - | After successful save |
refresh-history | - | After successful save |
Component Usage
Blade Template Example
Common Patterns
Listening for Edit Events
Dependencies
WeightLog
Carbon\Carbon- Date manipulationApp\Models\MeasurementWeight- Weight measurement model
HeartLog
Carbon\Carbon- Date manipulationApp\Models\MeasurementHeart- Heart measurement model
