<?php

namespace App\Http\Resources\Families;

use Illuminate\Http\Resources\Json\JsonResource;

class FamilyInvoiceResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => (int) ($this['id'] ?? 0),
            'parent_id' => (int) ($this['parent_id'] ?? 0),
            'invoice_number' => (string) ($this['invoice_number'] ?? ''),
            'status' => (string) ($this['status'] ?? ''),
            'total_amount' => (float) ($this['total_amount'] ?? 0),
            'paid_amount' => (float) ($this['paid_amount'] ?? 0),
            'balance' => (float) ($this['balance'] ?? 0),
            'issue_date' => $this['issue_date'] ?? null,
            'due_date' => $this['due_date'] ?? null,
        ];
    }
}
