<?php

namespace App\Http\Requests\Admin\Bank;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class CreateBankRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255|unique:banks,name',
            'oneapp_code' => 'nullable|string|max:20|unique:banks,oneapp_code',
            'paystack_code' => 'nullable|string|max:20|unique:banks,paystack_code',
            'monnify_code' => 'nullable|string|max:20|unique:banks,monnify_code',
            'safeheaven_code' => 'nullable|string|max:20|unique:banks,safeheaven_code',
            'fintava_short_code' => 'nullable|string|max:20|unique:banks,fintava_short_code',
            'bani_code' => 'nullable|string|max:20|unique:banks,bani_code',
            'bani_list_code' => 'nullable|string|max:20|unique:banks,bani_list_code',
            'kora_code' => 'nullable|string|max:20|unique:banks,kora_code',
            'status' => 'nullable|boolean',
        ];
    }

    public function messages()
    {
        return [
            'name.required' => 'Bank name is required.',
            'name.unique' => 'This bank name already exists.',
            'oneapp_code.unique' => 'This OneApp code already exists.',
            'paystack_code.unique' => 'This Paystack code already exists.',
            'monnify_code.unique' => 'This Monnify code already exists.',
            'safeheaven_code.unique' => 'This Safeheaven code already exists.',
            'fintava_short_code.unique' => 'This Fintava short code already exists.',
            'bani_code.unique' => 'This Bani code already exists.',
            'bani_list_code.unique' => 'This Bani list code already exists.',
            'kora_code.unique' => 'This Kora code already exists.',
        ];
    }
}
