<?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 UpdateEmpEducationsRequest extends FormRequest
{
    use FailedValidation;

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

            'emp_educations.*.id' => ['nullable', 'exists:emp_education,id'],
            'emp_educations.*.education_level_id' => ['required', 'exists:education_levels,id'],
            'emp_educations.*.institute' => ['required', 'string', 'max:255'],
            'emp_educations.*.major' => ['nullable', 'string', 'max:255'],

            'emp_educations.*.year' => ['nullable', 'digits:4'],

            'emp_educations.*.score' => ['nullable', 'numeric', 'between:0,999.99'],
            'emp_educations.*.scale' => ['nullable', 'numeric', 'between:0,9.99'],

            'emp_educations.*.start_date' => ['nullable', 'date'],
            'emp_educations.*.end_date' => ['nullable', 'date'],
        ];
    }


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