feat(backend): complete Module 5 (drop-off points + auto-assign)

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>
This commit is contained in:
2026-04-30 00:11:22 +08:00
parent 4eb2d14e52
commit 1150a518e8
23 changed files with 1040 additions and 9 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class DropOffPointResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->uuid,
'name' => $this->name,
'code' => $this->code,
'address_line' => $this->address_line,
'coordinates' => $this->coordinates ? [
'lat' => $this->coordinates->latitude,
'lng' => $this->coordinates->longitude,
] : null,
'capacity_kg' => $this->capacity_kg,
'operating_hours' => $this->operating_hours,
'accepted_waste_types' => $this->accepted_waste_types,
'status' => $this->status,
'photo_path' => $this->photo_path,
'contact_person' => $this->contact_person,
'contact_phone' => $this->contact_phone,
'distance_meters' => $this->when(
isset($this->distance_meters),
fn () => round((float) $this->distance_meters, 1),
),
'barangay' => BarangayResource::make($this->whenLoaded('barangay')),
];
}
}