<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ServiceTemplateItem extends Model
{
    use BelongsToTenant;

    public const KINDS = ['labor' => 'Manoperă', 'part' => 'Piesă'];

    protected $fillable = [
        'company_id', 'service_template_id', 'kind',
        'labor_id', 'part_id', 'name', 'qty', 'hours',
    ];

    protected $casts = [
        'qty' => 'decimal:2',
        'hours' => 'decimal:2',
    ];

    public function template(): BelongsTo
    {
        return $this->belongsTo(ServiceTemplate::class, 'service_template_id');
    }

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

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