<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreAppointmentRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'category_id' => ['required', 'exists:appointment_categories,id'],
            'date' => ['required', 'date'],
            'time' => ['required', 'date_format:H:i'],  // Assuming time in HH:MM format
            'title' => 'required|string|max:255',
            'description' => 'nullable|string',
            'urgency_degree' => "required|string|in:weak,medium,important,urgent,critical",
        ];
    }

    public function messages(): array
    {
        return [
            'time.date_format' => 'The time format should be HH:MM (24-hour format).',  // Custom error message for time format
        ];
    }
}
