<?php

namespace App\Http\Requests\Promotions;

use App\Http\Requests\ApiFormRequest;

class ParentEnrollmentStepRequest extends ApiFormRequest
{
    public function rules(): array
    {
        return [
            'info_confirmed' => ['nullable', 'boolean'],
            'documents_uploaded' => ['nullable', 'boolean'],
            'agreement_accepted' => ['nullable', 'boolean'],
            'payment_completed' => ['nullable', 'boolean'],
        ];
    }

    public function steps(): array
    {
        $data = $this->validated();
        $steps = [];
        foreach (['info_confirmed', 'documents_uploaded', 'agreement_accepted', 'payment_completed'] as $field) {
            if (array_key_exists($field, $data) && $data[$field] !== null) {
                $steps[$field] = (bool) $data[$field];
            }
        }
        return $steps;
    }
}
