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:
31
app/Http/Resources/Api/StationResource.php
Normal file
31
app/Http/Resources/Api/StationResource.php
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user