<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class InstallmentScheduleRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('installments.manage');
    }

    public function rules(): array
    {
        return [
            'months' => ['required', 'integer', 'min:1', 'max:36'],
            'down_payment' => ['sometimes', 'integer', 'min:0'],
            'first_due_date' => ['nullable', 'date', 'after_or_equal:today'],
        ];
    }
}
