<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255', 'unique:payroll_structures,name'],
            'description' => ['nullable', 'string'],
            'components' => ['required', 'array', 'min:1'],
            'components.*.salary_component_id' => ['required', 'exists:salary_components,id'],
            'components.*.calculation_type' => ['required', 'in:percentage,fixed'],
            'components.*.value' => ['required', 'numeric', 'min:0'],
        ];
    }
}
