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,41 @@
<?php
namespace App\Http\Requests\Api;
use App\Enums\FuelType;
use Illuminate\Foundation\Http\FormRequest;
class NearbyStationsRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'lat' => ['required', 'numeric', 'between:-90,90'],
'lng' => ['required', 'numeric', 'between:-180,180'],
'fuel_type' => ['required', 'string'],
'radius' => ['nullable', 'numeric', 'between:0.1,50'],
'sort' => ['nullable', 'string', 'in:price,distance'],
'pricing_mode' => ['nullable', 'string', 'in:pump'],
];
}
public function fuelType(): FuelType
{
return FuelType::fromAlias($this->string('fuel_type')->toString());
}
public function radius(): float
{
return (float) $this->input('radius', 10.0);
}
public function sort(): string
{
return $this->input('sort', 'price');
}
}