'decimal:2', 'actual_qty' => 'decimal:2', 'unit_cost' => 'decimal:2', ]; } public function task(): BelongsTo { return $this->belongsTo(Task::class); } public function material(): BelongsTo { return $this->belongsTo(Material::class); } public function getPlannedCostAttribute(): float { return (float) $this->planned_qty * (float) $this->unit_cost; } public function getActualCostAttribute(): float { return (float) $this->actual_qty * (float) $this->unit_cost; } public function getEffectiveCostAttribute(): float { return $this->actual_qty > 0 ? $this->actual_cost : $this->planned_cost; } public function getVarianceAttribute(): float { return $this->planned_cost - $this->actual_cost; } }