<?php

namespace App\Http\Requests\Admin\Settings;

use Illuminate\Foundation\Http\FormRequest;

class WithdrawMethodRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return auth('admin')->check();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255',
            'image' => 'nullable|string',
            'min' => 'required|numeric',
            'max' => 'required|numeric',
            'currency' => 'required|exists:currencies,code',
            'percent_charge' => 'required|numeric',
            'fixed_charge' => 'required|numeric',
            'instructions' => 'nullable|string|max:255',
            'fields' => 'nullable|array',
            'fields.*.label' => 'required|string',
            'fields.*.field_type' => 'required|in:text,number,textarea,select,radio,checkbox',
            'fields.*.required' => 'required|in:0,1',
            'fields.*.order' => 'required|numeric',
            'status' => 'nullable|in:active,inactive',
        ];
    }
}
