<?php

namespace App\Modules\HR\EmployeeSelfService\Requests;

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

class MeLoanRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->employee_id !== null;
    }

    public function rules(): array
    {
        return [
            'type' => ['required', Rule::in(['loan', 'advance'])], 'amount' => ['required', 'numeric', 'gt:0'],
            'installment_count' => ['required', 'integer', 'min:1', 'max:120'], 'start_date' => ['required', 'date'],
            'reason' => ['nullable', 'string', 'max:5000'], 'notes' => ['nullable', 'string', 'max:5000'],
        ];
    }
}
