'decimal:2', 'quantity_used' => 'decimal:4', ]; /** * Tipos de item disponíveis */ public const TYPES = [ 'supply' => 'Insumo', 'consumable' => 'Descartável', 'material' => 'Material', 'equipment_usage' => 'Uso de Equipamento', 'other' => 'Outro', ]; /** * Relacionamento com ficha de serviço */ public function serviceSheet(): BelongsTo { return $this->belongsTo(ServiceSheet::class); } /** * Calcula o custo total do item * Custo Total = Custo Unitário × Quantidade Usada */ public function getTotalCostAttribute(): float { return round((float) $this->unit_cost * (float) $this->quantity_used, 2); } /** * Retorna o nome do tipo traduzido */ public function getTypeNameAttribute(): string { return self::TYPES[$this->type] ?? $this->type; } }