add family logic

This commit is contained in:
root
2026-03-10 17:52:47 -04:00
parent a82f7aedbc
commit 17d73e2f92
37 changed files with 2611 additions and 2 deletions
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Resources\Families;
use Illuminate\Http\Resources\Json\JsonResource;
class FamilyResource extends JsonResource
{
public function toArray($request): array
{
return [
'id' => (int) ($this['id'] ?? 0),
'family_code' => (string) ($this['family_code'] ?? ''),
'household_name' => (string) ($this['household_name'] ?? ''),
'address_line1' => (string) ($this['address_line1'] ?? ''),
'address_line2' => (string) ($this['address_line2'] ?? ''),
'city' => (string) ($this['city'] ?? ''),
'state' => (string) ($this['state'] ?? ''),
'postal_code' => (string) ($this['postal_code'] ?? ''),
'country' => (string) ($this['country'] ?? ''),
'primary_phone' => (string) ($this['primary_phone'] ?? ''),
'preferred_lang' => (string) ($this['preferred_lang'] ?? ''),
'preferred_contact_method' => (string) ($this['preferred_contact_method'] ?? ''),
'is_active' => (bool) ($this['is_active'] ?? false),
'is_primary_home' => (bool) ($this['is_primary_home'] ?? false),
'guardians' => FamilyGuardianResource::collection($this['guardians'] ?? []),
'students' => FamilyStudentResource::collection($this['students'] ?? []),
'invoices' => FamilyInvoiceResource::collection($this['invoices'] ?? []),
'payments' => FamilyPaymentResource::collection($this['payments'] ?? []),
'emergency_contacts' => FamilyEmergencyContactResource::collection($this['emergency_contacts'] ?? []),
'finance_summary' => $this['finance_summary'] ?? [
'invoices_count' => 0,
'total_amount' => 0.0,
'paid_amount' => 0.0,
'balance' => 0.0,
],
'invoice_map' => $this['invoice_map'] ?? [],
];
}
}