<?php

namespace App\Http\Requests\Whatsapp;

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

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

    public function rules(): array
    {
        return [
            'school_year' => ['nullable', 'string', 'max:20'],
            'semester' => ['nullable', 'string', 'max:20'],
            'class_section_id' => ['nullable', 'integer', 'min:1'],
            'active' => ['nullable', 'boolean'],
            'search' => ['nullable', 'string', 'max:2000'],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:200'],
            'page' => ['nullable', 'integer', 'min:1'],
            'sort_by' => ['nullable', 'string', Rule::in([
                'class_section_id',
                'class_section_name',
                'school_year',
                'semester',
                'active',
                'updated_at',
            ])],
            'sort_dir' => ['nullable', 'string', Rule::in(['asc', 'desc'])],
        ];
    }
}
