<?php

namespace App\Http\Requests\Classes;

use App\Http\Requests\ApiFormRequest;

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

    public function rules(): array
    {
        return [
            'search' => ['nullable', 'string', 'max:120'],
            'class_id' => ['nullable', 'integer', 'min:1'],
            'school_year' => ['nullable', 'string', 'max:9'],
            'semester' => ['nullable', 'string', 'max:255'],
            'with_students' => ['nullable', 'boolean'],
            'sort_by' => ['nullable', 'string', 'in:class_section_name,class_section_id,class_id,school_year,semester,class_name'],
            'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
            'page' => ['nullable', 'integer', 'min:1'],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
        ];
    }
}
