<?php

namespace App\Http\Requests\Whatsapp;

use App\Http\Requests\ApiFormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            'mode' => ['required', 'string', Rule::in(['parents', 'class', 'all'])],
            'class_section_id' => ['required_if:mode,class', 'integer', 'min:1'],
            'parent_ids' => ['required_if:mode,parents', 'array'],
            'parent_ids.*' => ['integer', 'min:1'],
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
        ];
    }
}
