<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateSettingsRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->hasPermission('settings.manage') ?? false;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'property_name' => ['required', 'string', 'max:255'],
            'timezone' => ['required', 'string', 'max:64'],
            'currency' => ['required', 'string', 'max:10'],
            'currency_symbol' => ['required', 'string', 'max:10'],
            'date_format' => ['required', 'string', 'max:32'],
            'time_format' => ['required', 'string', 'max:32'],
            'default_tax' => ['required', 'numeric', 'min:0', 'max:100'],
            'default_service_charge' => ['required', 'numeric', 'min:0', 'max:100'],
            'default_quotation_validity_days' => ['required', 'integer', 'min:1', 'max:365'],
            'default_hold_duration_hours' => ['required', 'integer', 'min:1', 'max:720'],
            'default_deposit_percentage' => ['required', 'numeric', 'min:0', 'max:100'],
            'booking_prefix' => ['required', 'string', 'max:10'],
            'quotation_prefix' => ['required', 'string', 'max:10'],
            'invoice_prefix' => ['required', 'string', 'max:10'],
            'payment_prefix' => ['required', 'string', 'max:10'],
            'number_padding' => ['required', 'integer', 'min:3', 'max:12'],
            'company_address' => ['nullable', 'string', 'max:1000'],
            'company_phone' => ['nullable', 'string', 'max:30'],
            'company_email' => ['nullable', 'email', 'max:255'],
        ];
    }
}
