drop_off_points (with SPATIAL INDEX on coordinates) +
drop_off_capacity_logs. Public nearby query via ST_Distance_Sphere
returns DOPs sorted by distance with distance_meters in payload.
Admin CRUD plus capacity-log endpoint. Household creation auto-assigns
to the nearest active DOP within 25km; resident can re-run the lookup
via POST /households/{uuid}/reassign-drop-off.
97 feature tests passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.4 KiB
PHP
34 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class HouseholdResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'address_line' => $this->address_line,
|
|
'household_size' => $this->household_size,
|
|
'coordinates' => $this->coordinates ? [
|
|
'lat' => $this->coordinates->latitude,
|
|
'lng' => $this->coordinates->longitude,
|
|
] : null,
|
|
'barangay' => BarangayResource::make($this->whenLoaded('barangay')),
|
|
'head' => UserResource::make($this->whenLoaded('head')),
|
|
'verification_status' => $this->verification_status,
|
|
'verified_at' => $this->verified_at?->toIso8601String(),
|
|
'rejection_reason' => $this->rejection_reason,
|
|
'proof_of_residency_uploaded' => (bool) $this->proof_of_residency_path,
|
|
'assigned_drop_off_point' => DropOffPointResource::make($this->whenLoaded('assignedDropOffPoint')),
|
|
'members' => HouseholdMemberResource::collection($this->whenLoaded('members')),
|
|
'member_count' => $this->whenCounted('members'),
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
'updated_at' => $this->updated_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|