<?php

namespace App\Http\Resources\Invoices;

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

class InvoiceManagementParentResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'parent_name' => $this->resource['parent_name'] ?? '',
            'parent_id' => (int) ($this->resource['parent_id'] ?? 0),
            'enrolledKids' => $this->resource['enrolledKids'] ?? [],
            'withdrawnKids' => $this->resource['withdrawnKids'] ?? [],
            'invoice_amount' => (float) ($this->resource['invoice_amount'] ?? 0),
            'refund_amount' => (float) ($this->resource['refund_amount'] ?? 0),
            'last_updated' => $this->resource['last_updated'] ?? null,
            'invoice_date' => $this->resource['invoice_date'] ?? null,
            'invoice_id' => $this->resource['invoice_id'] ?? null,
        ];
    }
}
