<?php

namespace App\Http\Requests\Payments;

use Illuminate\Foundation\Http\FormRequest;

class StorePaymentProofRequest extends FormRequest
{
    public function authorize(): bool
    {
        $registration = $this->route('registration');

        return $registration
            && $this->user()?->can('view', $registration)
            && $this->user()?->can('create', \App\Models\EventPaymentProof::class);
    }

    public function rules(): array
    {
        return [
            'manual_payment_method_id' => ['required', 'integer', 'exists:manual_payment_methods,id'],
            'transfer_reference' => ['nullable', 'string', 'max:255'],
            'user_notes' => ['nullable', 'string', 'max:2000'],
            'proof' => ['required', 'file', 'mimes:jpg,jpeg,png,webp,pdf', 'max:10240'],
        ];
    }
}
