<?php

namespace Modules\Patient\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\Core\Enums\StatusEnum;
use Modules\Core\Traits\FailedValidation;

class ZakatFundRequest extends FormRequest
{
    use FailedValidation;

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        $zakatFundId = $this->route('zakat_fund');

        return [
            'name' => [
                'required',
                'string',
                'max:255',
            ],
            'code' => [
                'nullable',
                'string',
                'max:255',
                Rule::unique('zakat_funds', 'code')->ignore($zakatFundId),
            ],
            'status' => [
                'required',
                Rule::enum(StatusEnum::class),
            ],
            'priority' => [
                'nullable',
                'integer',
            ],
            'amount' => [
                'nullable',
                'numeric',
            ],
        ];
    }
}
