<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ServiceItem extends Model
{
    /** @use HasFactory<\Database\Factories\ServiceItemFactory> */
    use HasFactory;

    protected $fillable = [
        'service_order_id',
        'service_name',
        'description',
        'category',
        'labor_rate',
        'estimated_hours',
        'actual_hours',
        'labor_cost',
        'status',
        'technician_notes',
    ];

    protected $casts = [
        'labor_rate' => 'decimal:2',
        'estimated_hours' => 'decimal:2',
        'actual_hours' => 'decimal:2',
        'labor_cost' => 'decimal:2',
    ];

    public function serviceOrder(): BelongsTo
    {
        return $this->belongsTo(ServiceOrder::class);
    }
}
