<?php

namespace App\Http\Requests\Exam;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'title' => ['required', 'string', 'max:190'],
            'classroom_id' => ['required', 'integer'],
            'subject_id' => ['required', 'integer'],
            'type' => ['required', 'in:test,descriptive,mixed,file,offline'],
            'starts_at' => ['nullable', 'date'],
            'ends_at' => ['nullable', 'date', 'after_or_equal:starts_at'],
            'duration_minutes' => ['nullable', 'integer', 'min:1', 'max:600'],
            'max_score' => ['nullable', 'numeric', 'min:1', 'max:100'],
        ];
    }
}
