<?php
namespace App\DTOs\Admin;

class TemplateSectionDto{
    public int $id;
    public string $title;
    public string $templateName;
    public int $order;
    public array $sectionRules;

     public function __construct(array $data)
    {
        $this->id = $data['id'];
        $this->title = $data['title'];
        $this->templateName = $data['templateName'];
        $this->order = $data['order'];
        $this->sectionRules = $data['sectionRules'] ?? [];
    }

    public static function fromRequest(\Illuminate\Http\Request $request): self
    {
        return new self($request->only(['id', 'title', 'order', 'sectionRules', 'templateName']));
    }
}