<?php

namespace App\Http\Requests\Reports\Stickers;

use App\Http\Requests\ApiFormRequest;

class StickerStudentsByClassRequest 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 [
            'class_section_id' => ['required', 'integer', 'min:1'],
            'school_year' => ['nullable', 'string', 'max:20'],
        ];
    }
}
