<?php

namespace App\Http\Requests\ClassPreparation;

use App\Http\Requests\ApiFormRequest;

class ClassPreparationPrintRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null || auth()->user() !== null;
    }

    protected function prepareForValidation(): void
    {
        parent::prepareForValidation();

        $this->merge([
            'class_section_id' => $this->route('classSectionId'),
            'school_year' => $this->route('schoolYear'),
        ]);
    }

    public function rules(): array
    {
        return [
            'class_section_id' => ['required', 'string', 'max:32'],
            'school_year' => ['required', 'string', 'max:9'],
            'semester' => ['nullable', 'string', 'max:255'],
        ];
    }
}
