<?php

namespace App\Http\Requests\V1\WorkSetting;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'use_gps' => ['sometimes', 'boolean'],
            'use_auto' => ['sometimes', 'boolean'],
            'allowed_radius' => ['sometimes', 'integer', 'min:10', 'max:10000'],
            'hq_address' => ['nullable', 'string', 'max:255'],
            'hq_latitude' => ['nullable', 'numeric', 'between:-90,90'],
            'hq_longitude' => ['nullable', 'numeric', 'between:-180,180'],
        ];
    }

    public function messages(): array
    {
        return [
            'allowed_radius.min' => __('error.attendance_setting.radius_too_small'),
            'allowed_radius.max' => __('error.attendance_setting.radius_too_large'),
            'hq_latitude.between' => __('error.attendance_setting.invalid_latitude'),
            'hq_longitude.between' => __('error.attendance_setting.invalid_longitude'),
        ];
    }
}
