table = 'electricity_bills'; $this->guarded = []; } /** * Calculate total amount based on reading difference and unit price */ public function calculateTotal(): float { $consumption = $this->current_reading - $this->previous_reading; return round($consumption * $this->unit_price, 2); } /** * Get consumption in kWh */ public function getConsumption(): float { return $this->current_reading - $this->previous_reading; } /** * Get user who created this record */ public function creator() { return $this->belongsTo(\App\Models\User::class, 'created_by'); } /** * Get user who updated this record */ public function updater() { return $this->belongsTo(\App\Models\User::class, 'updated_by'); } }