<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ProcedureRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('settings.manage');
    }

    public function rules(): array
    {
        return [
            'name_en' => ['required', 'string', 'max:190'],
            'name_ar' => ['required', 'string', 'max:190'],
            'category' => ['required', Rule::in(config('dental.procedure_categories'))],
            'code' => ['nullable', 'string', 'max:32'],
            'default_price' => ['required', 'integer', 'min:0', 'max:100000000'],
            'default_duration_min' => ['required', 'integer', 'min:5', 'max:480'],
            'default_condition' => ['nullable', Rule::in(array_keys(config('dental.conditions')))],
            'is_active' => ['sometimes', 'boolean'],
        ];
    }
}
