<?php

namespace Modules\Employee\Http\Requests\Employee;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\Core\Enums\StatusEnum;
use Modules\Core\Traits\FailedValidation;

class UpdateEmpEmergencyContactRequest extends FormRequest
{
    use FailedValidation;

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'emergencies' => ['required', 'array'],

            'emergencies.*.id' => ['nullable', 'exists:emp_emergencies,id'],
            'emergencies.*.name' => ['required', 'string', 'max:100'],
            'emergencies.*.phone' => ['required', 'string', 'max:20'],
            'emergencies.*.relation' => ['required', 'string', 'max:50'],
            'emergencies.*.address' => ['nullable', 'string', 'max:255'],
        ];
    }


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