<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class TaxSettingsUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return $this->user()->can('updateSettings', \App\Models\TaxRule::class);
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'default_tax_rate' => ['nullable', 'numeric', 'min:0', 'max:100'],
            'taxable_types' => ['optional', 'array', 'min:1'],
            'taxable_types.*' => ['in:domain,hosting'],
            'tax_method' => ['required', 'in:inclusive,exclusive'],
            'tax_id_required' => ['required', 'in:0,1'],
            'show_company_tax_info' => ['required', 'in:0,1'],
            'company_tax_info' => ['nullable', 'string'],
        ];
    }
}
