diff --git a/app/Http/Controllers/API/v1/TransportController.php b/app/Http/Controllers/API/v1/TransportController.php index 863e7ec1c..9c0ab4d50 100644 --- a/app/Http/Controllers/API/v1/TransportController.php +++ b/app/Http/Controllers/API/v1/TransportController.php @@ -75,11 +75,10 @@ public function getTrip(Request $request): JsonResponse { $validated['lineName'], $validated['start'] ); + return $this->sendv1Response(data: $trainTripResponse); } catch (StationNotOnTripException) { return $this->sendv1Error(__('controller.transport.not-in-stopovers'), 400); } - - return $this->sendv1Response(data: $trainTripResponse); } public function getNextStationByCoordinates(Request $request): JsonResponse { diff --git a/app/Http/Resources/HafasTripResource.php b/app/Http/Resources/HafasTripResource.php index a6ffcfebc..70c92d0c7 100644 --- a/app/Http/Resources/HafasTripResource.php +++ b/app/Http/Resources/HafasTripResource.php @@ -21,7 +21,7 @@ public function toArray($request): array { "lineName" => $this->linename, "origin" => new TrainStationResource($this->originStation), "destination" => new TrainStationResource($this->destinationStation), - "stopovers" => StopoverResource::collection($this->stopoversNEW->sortBy('departure')) + "stopovers" => StopoverResource::collection($this->stopoversNEW) ]; } } diff --git a/app/Models/HafasTrip.php b/app/Models/HafasTrip.php index 183e6143e..066359d87 100644 --- a/app/Models/HafasTrip.php +++ b/app/Models/HafasTrip.php @@ -55,6 +55,8 @@ public function remarks(): BelongsToMany { public function stopoversNEW(): HasMany { //TODO: Rename to ->stopovers when old attribute is gone - return $this->hasMany(TrainStopover::class, 'trip_id', 'trip_id')->orderBy('arrival_planned'); + return $this->hasMany(TrainStopover::class, 'trip_id', 'trip_id') + ->orderBy('arrival_planned') + ->orderBy('departure_planned'); } }