<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\Offers\Models;

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

class OfferSection extends Model
{
    protected $table = 'offer_sections';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'offer_id',
        'title',
        'description_html',
        'sort_order',
    ];

    /**
     * @return BelongsTo<Offer, OfferSection>
     */
    public function offer(): BelongsTo
    {
        return $this->belongsTo(Offer::class);
    }

    /**
     * @return HasMany<OfferRow, OfferSection>
     */
    public function rows(): HasMany
    {
        return $this->hasMany(OfferRow::class)->orderBy('sort_order');
    }
}
