<?php

namespace App\Http\Requests\Events;

use App\Http\Requests\ApiFormRequest;

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

    public function rules(): array
    {
        return [
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
            'q' => ['nullable', 'string', 'max:200'],
            'active' => ['nullable', 'boolean'],
            'page' => ['nullable', 'integer', 'min:1'],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
            'sort_by' => ['nullable', 'string', 'in:created_at,expiration_date,event_name'],
            'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
        ];
    }
}
