<?php

namespace App\Http\Requests\Reports\Stickers;

use App\Http\Requests\ApiFormRequest;

class StickerFormDataRequest extends ApiFormRequest
{
    protected function prepareForValidation(): void
    {
        parent::prepareForValidation();

        if (!$this->has('class_section_id') && $this->has('class_id')) {
            $this->merge(['class_section_id' => $this->input('class_id')]);
        }
    }

    public function authorize(): bool
    {
        return auth()->check();
    }

    public function rules(): array
    {
        return [
            'school_year' => ['nullable', 'string', 'max:20'],
            'class_section_id' => ['nullable', 'integer', 'min:1'],
        ];
    }
}
