<?php

namespace App\Http\Requests\Voting;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'title' => ['required', 'string', 'max:190'],
            'type' => ['required', 'in:student_council,class_representative,survey,custom'],
            'description' => ['nullable', 'string', 'max:2000'],
            'starts_at' => ['nullable', 'date'],
            'ends_at' => ['nullable', 'date', 'after_or_equal:starts_at'],
            'grade_level_ids' => ['nullable', 'array'],
            'grade_level_ids.*' => ['integer'],
            'classroom_ids' => ['nullable', 'array'],
            'classroom_ids.*' => ['integer'],
        ];
    }
}
