<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\Offers\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Maestro\Core\Modules\Offers\Models\OfferSection;

/** @property OfferSection $resource */
final class OfferSectionResource extends JsonResource
{
    /**
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'offer_id' => $this->offer_id,
            'title' => $this->title,
            'description_html' => $this->description_html,
            'sort_order' => (int) $this->sort_order,
            'rows' => OfferRowResource::collection($this->whenLoaded('rows')),
        ];
    }
}
