<?php

namespace App\Http\Resources\Payments;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class PaymentTransactionResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'transaction_id' => $this->resource['transaction_id'] ?? null,
            'payment_id' => (int) ($this->resource['payment_id'] ?? 0),
            'transaction_date' => $this->resource['transaction_date'] ?? null,
            'amount' => (float) ($this->resource['amount'] ?? 0),
            'payment_method' => $this->resource['payment_method'] ?? null,
            'payment_status' => $this->resource['payment_status'] ?? null,
            'transaction_fee' => isset($this->resource['transaction_fee']) ? (float) $this->resource['transaction_fee'] : null,
            'payment_reference' => $this->resource['payment_reference'] ?? null,
            'is_full_payment' => isset($this->resource['is_full_payment']) ? (bool) $this->resource['is_full_payment'] : null,
            'school_year' => $this->resource['school_year'] ?? null,
            'semester' => $this->resource['semester'] ?? null,
        ];
    }
}
