feat: add GET /api/stations nearby stations endpoint with haversine query and search logging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ovidiu U
2026-04-04 19:27:55 +01:00
parent cf6a1369d4
commit 8bd43ee9e4
4 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources\Api;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
class StationResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'station_id' => $this->node_id,
'name' => $this->trading_name,
'brand' => $this->brand_name,
'is_supermarket' => (bool) $this->is_supermarket,
'address' => implode(', ', array_filter([$this->address_line_1, $this->city])),
'postcode' => $this->postcode,
'lat' => (float) $this->lat,
'lng' => (float) $this->lng,
'distance_km' => round((float) $this->distance_km, 2),
'fuel_type' => $this->fuel_type,
'price_pence' => (int) $this->price_pence,
'price' => round((int) $this->price_pence / 100, 2),
'price_updated_at' => $this->price_effective_at
? Carbon::parse($this->price_effective_at)->toISOString()
: null,
];
}
}