From ff85ea4596fa0a9e54f9fb83324e607e85764e72 Mon Sep 17 00:00:00 2001 From: Levin Herr Date: Sun, 15 Oct 2023 23:00:58 +0200 Subject: [PATCH] :bug: Add timezone to trip creation (#1985) --- .../Frontend/Admin/TripController.php | 19 ++++++++++++------- resources/views/admin/trip/create.blade.php | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Frontend/Admin/TripController.php b/app/Http/Controllers/Frontend/Admin/TripController.php index 9391f5921..f8a866325 100644 --- a/app/Http/Controllers/Frontend/Admin/TripController.php +++ b/app/Http/Controllers/Frontend/Admin/TripController.php @@ -48,6 +48,11 @@ public function createTrip(Request $request): RedirectResponse { 'journey_number' => ['required', 'numeric'], ]); + $departure = str_contains($validated['departure'], '+') && str_contains($validated['departure'], '-') + ? $validated['departure'] : $validated['departure'] . '+00:00'; + $arrival = str_contains($validated['arrival'], '+') && str_contains($validated['arrival'], '-') + ? $validated['arrival'] : $validated['arrival'] . '+00:00'; + $originStation = TrainStation::where('ibnr', $validated['origin'])->firstOrFail(); $destinationStation = TrainStation::where('ibnr', $validated['destination'])->firstOrFail(); @@ -63,29 +68,29 @@ public function createTrip(Request $request): RedirectResponse { 'operator_id' => $validated['operator_id'], 'origin' => $validated['origin'], 'destination' => $validated['destination'], - 'departure' => $validated['departure'], - 'arrival' => $validated['arrival'], + 'departure' => $departure, + 'arrival' => $arrival, ]); //Origin stopover TrainStopover::create([ 'trip_id' => $trip->trip_id, 'train_station_id' => $originStation->id, - 'arrival_planned' => $validated['departure'], - 'departure_planned' => $validated['departure'], + 'arrival_planned' => $departure, + 'departure_planned' => $departure, ]); //Destination stopover TrainStopover::create([ 'trip_id' => $trip->trip_id, 'train_station_id' => $destinationStation->id, - 'arrival_planned' => $validated['arrival'], - 'departure_planned' => $validated['arrival'], + 'arrival_planned' => $arrival, + 'departure_planned' => $arrival, ]); return redirect()->route('trains.trip', [ 'tripID' => $trip->trip_id, 'lineName' => $trip->linename, 'start' => $trip->origin, - 'departure' => $validated['departure'], + 'departure' => $departure, ]); } } diff --git a/resources/views/admin/trip/create.blade.php b/resources/views/admin/trip/create.blade.php index 27dd969e8..7d8f8d66f 100644 --- a/resources/views/admin/trip/create.blade.php +++ b/resources/views/admin/trip/create.blade.php @@ -23,7 +23,7 @@
- +
@@ -35,7 +35,7 @@
- +