<?php

namespace App\Http\Requests;

use App\Services\ClinicSettings;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AppointmentUpdateRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        $types = $this->user()
            ? app(ClinicSettings::class)->appointmentTypes($this->user()->organization_id)
            : ['new_consultation', 'follow_up', 'routine', 'emergency'];

        return [
            'type' => ['sometimes', 'string', 'max:80', Rule::in($types)],
            'reason' => ['nullable', 'string', 'max:3000'],
        ];
    }
}
