<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        // Reseller-disabled toggle path skips all field rules — controller
        // calls $request->validated() only after checking the enabled flag.
        if (! $this->boolean('enabled')) {
            return [];
        }

        return [
            'status' => ['required', 'in:pending,active,suspended,terminated'],
            'brand_name' => ['nullable', 'string', 'max:255'],
            'logo' => ['nullable', 'string', 'max:500'],
            'group_id' => ['nullable', 'exists:client_groups,id'],
            'commission_type' => ['required', 'in:percentage,fixed'],
            'commission_rate' => ['required', 'numeric', 'min:0'],
            'credit_limit' => ['nullable', 'numeric', 'min:0'],
            'max_clients' => ['nullable', 'integer', 'min:0'],
            'notes' => ['nullable', 'string'],
        ];
    }
}
