<?php

namespace App\Models\Tenant;

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

class ServiceTemplate extends Model
{
    use BelongsToTenant, SoftDeletes;

    protected $fillable = ['company_id', 'name', 'category', 'notes', 'is_active'];

    protected $casts = ['is_active' => 'boolean'];

    public function items(): HasMany
    {
        return $this->hasMany(ServiceTemplateItem::class);
    }

    public function laborItems(): HasMany
    {
        return $this->items()->where('kind', 'labor');
    }

    public function partItems(): HasMany
    {
        return $this->items()->where('kind', 'part');
    }
}
