<?php

namespace App\Http\Requests;

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

class StorePaymentRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('finance.create-payment');
    }

    public function rules(): array
    {
        return [
            'dealer_id' => ['required', 'exists:dealers,id'],
            'amount' => ['required', 'numeric', 'min:0.01'],
            'payment_date' => ['required', 'date'],
            'description' => ['nullable', 'string'],
            'payment_type' => ['required', Rule::in(['havale', 'eft', 'nakit', 'diger'])],
            'receipt_file' => ['nullable', 'file', 'max:5120'],
        ];
    }
}
