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>
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?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')),
|
|
];
|
|
}
|
|
}
|