add family logic
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Families;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FamilyEmergencyContactResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'parent_id' => (int) ($this['parent_id'] ?? 0),
|
||||
'parent_label' => (string) ($this['parent_label'] ?? ''),
|
||||
'emergency_contact_name' => (string) ($this['emergency_contact_name'] ?? ''),
|
||||
'relation' => (string) ($this['relation'] ?? ''),
|
||||
'cellphone' => (string) ($this['cellphone'] ?? ''),
|
||||
'email' => (string) ($this['email'] ?? ''),
|
||||
'school_year' => (string) ($this['school_year'] ?? ''),
|
||||
'semester' => (string) ($this['semester'] ?? ''),
|
||||
'created_at' => $this['created_at'] ?? null,
|
||||
'updated_at' => $this['updated_at'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Families;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FamilyGuardianResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'user_id' => (int) ($this['user_id'] ?? 0),
|
||||
'firstname' => (string) ($this['firstname'] ?? ''),
|
||||
'lastname' => (string) ($this['lastname'] ?? ''),
|
||||
'email' => (string) ($this['email'] ?? ''),
|
||||
'cellphone' => (string) ($this['cellphone'] ?? ''),
|
||||
'address_street' => (string) ($this['address_street'] ?? ''),
|
||||
'city' => (string) ($this['city'] ?? ''),
|
||||
'state' => (string) ($this['state'] ?? ''),
|
||||
'zip' => (string) ($this['zip'] ?? ''),
|
||||
'relation' => (string) ($this['relation'] ?? ''),
|
||||
'is_primary' => (bool) ($this['is_primary'] ?? false),
|
||||
'receive_emails' => (bool) ($this['receive_emails'] ?? false),
|
||||
'receive_sms' => (bool) ($this['receive_sms'] ?? false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Families;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FamilyPaymentResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'parent_id' => (int) ($this['parent_id'] ?? 0),
|
||||
'invoice_id' => (int) ($this['invoice_id'] ?? 0),
|
||||
'paid_amount' => (float) ($this['paid_amount'] ?? 0),
|
||||
'balance' => (float) ($this['balance'] ?? 0),
|
||||
'payment_method' => (string) ($this['payment_method'] ?? ''),
|
||||
'payment_date' => $this['payment_date'] ?? null,
|
||||
'status' => (string) ($this['status'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'] ?? [],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Families;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FamilySearchItemResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'type' => (string) ($this['type'] ?? ''),
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'label' => (string) ($this['label'] ?? ''),
|
||||
'sub' => (string) ($this['sub'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Families;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FamilyStudentResource extends JsonResource
|
||||
{
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($this['id'] ?? 0),
|
||||
'firstname' => (string) ($this['firstname'] ?? ''),
|
||||
'lastname' => (string) ($this['lastname'] ?? ''),
|
||||
'grade' => (string) ($this['grade'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user