feat: add price classification enum and reliable sort option
This commit is contained in:
@@ -20,7 +20,7 @@ class NearbyStationsRequest extends FormRequest
|
||||
'lng' => ['required_without:postcode', 'nullable', 'numeric', 'between:-180,180'],
|
||||
'fuel_type' => ['required', 'string'],
|
||||
'radius' => ['nullable', 'numeric', 'between:0.1,50'],
|
||||
'sort' => ['nullable', 'string', 'in:price,distance,updated,brand'],
|
||||
'sort' => ['nullable', 'string', 'in:price,distance,updated,brand,reliable'],
|
||||
'pricing_mode' => ['nullable', 'string', 'in:pump'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources\Api;
|
||||
|
||||
use App\Enums\PriceClassification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -26,6 +27,12 @@ class StationResource extends JsonResource
|
||||
'price_updated_at' => $this->price_effective_at
|
||||
? Carbon::parse($this->price_effective_at)->toISOString()
|
||||
: null,
|
||||
'price_classification' => PriceClassification::fromUpdatedAt(
|
||||
$this->price_effective_at ? Carbon::parse($this->price_effective_at) : null
|
||||
)->value,
|
||||
'price_classification_label' => PriceClassification::fromUpdatedAt(
|
||||
$this->price_effective_at ? Carbon::parse($this->price_effective_at) : null
|
||||
)->label(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user