<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            'name'                     => ['required', 'string', 'max:150'],
            'phone'                    => ['nullable', 'string', 'max:20'],
            'address'                  => ['nullable', 'string', 'max:500'],
            'notes'                    => ['nullable', 'string', 'max:1000'],
            'default_commission_type'  => ['required', Rule::in(['percent', 'fixed'])],
            'default_commission_value' => ['required', 'numeric', 'min:0', 'max:100000'],
            'is_active'                => ['boolean'],
        ];
    }

    public function messages(): array
    {
        return [
            'name.required'                     => 'Nama mitra wajib diisi.',
            'default_commission_type.required'  => 'Tipe komisi wajib dipilih.',
            'default_commission_value.required' => 'Nilai komisi wajib diisi.',
            'default_commission_value.min'      => 'Nilai komisi tidak boleh negatif.',
        ];
    }
}
