<?php

namespace App\Http\Requests\Settings;

use App\Http\Requests\ApiFormRequest;
use App\Services\Settings\SchoolCalendar\SchoolCalendarContextService;
use Illuminate\Validation\Rule;

class SchoolCalendarStoreRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return auth()->check();
    }

    public function rules(): array
    {
        $eventTypes = app(SchoolCalendarContextService::class)->eventTypes();

        return [
            'title' => ['required', 'string', 'min:3', 'max:255'],
            'description' => ['nullable', 'string'],
            'event_type' => ['nullable', 'string', Rule::in($eventTypes)],
            'date' => ['required', 'date_format:Y-m-d'],
            'notify_parent' => ['nullable', 'boolean'],
            'notify_teacher' => ['nullable', 'boolean'],
            'notify_admin' => ['nullable', 'boolean'],
            'no_school' => ['nullable', 'boolean'],
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
            'send_email_parent' => ['nullable', 'boolean'],
            'send_email_teacher' => ['nullable', 'boolean'],
            'send_email_admin' => ['nullable', 'boolean'],
        ];
    }
}
