<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\Offers\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class OfferServiceCatalogItem extends Model
{
    protected $table = 'offer_service_catalog_items';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'name',
        'default_description',
        'default_pricing_type',
        'default_custom_unit_label',
        'default_unit_price',
        'default_quantity',
        'default_vat_rate',
        'is_active',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'is_active' => 'boolean',
        ];
    }

    /**
     * @return HasMany<OfferRow, $this>
     */
    public function offerRows(): HasMany
    {
        return $this->hasMany(OfferRow::class, 'offer_service_catalog_item_id');
    }
}
