<?php

namespace Modules\Payroll\Http\Requests\EmployeeLoan;

use Illuminate\Foundation\Http\FormRequest;
use Modules\Core\Traits\FailedValidation;

class StoreEmployeeLoanRequest extends FormRequest
{
    use FailedValidation;

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

    /**
     * Get the validation rules that apply to the request.
     */

    public function rules(): array
    {
        return [
            'employee_id'            => ['required', 'exists:employees,id'],
            'loan_type'               => ['nullable', 'string', 'max:100'],
            'principal_amount'        => ['required', 'numeric', 'min:1'],
            'interest_rate'           => ['nullable', 'numeric', 'min:0', 'max:100'],
            'installment_months'      => ['required', 'integer', 'min:1', 'max:60'],
            'issue_date'               => ['required', 'date'],
            'start_deduction_date'     => ['required', 'date', 'after_or_equal:issue_date'],
            'remarks'                  => ['nullable', 'string', 'max:1000'],
        ];
    }
}
