diff --git a/app/Http/Controllers/API/v1/TripController.php b/app/Http/Controllers/API/v1/TripController.php index 118b50e4f..bd9a978f7 100644 --- a/app/Http/Controllers/API/v1/TripController.php +++ b/app/Http/Controllers/API/v1/TripController.php @@ -36,8 +36,8 @@ public function createTrip(Request $request): HafasTripResource { $validated = $request->validate([ 'category' => ['required', new Enum(HafasTravelType::class)], 'lineName' => ['required'], - 'journey_number' => ['nullable', 'numeric', 'min:1'], - 'operator_id' => ['nullable', 'numeric', 'exists:hafas_operators,id'], + 'journeyNumber' => ['nullable', 'numeric', 'min:1'], + 'operatorId' => ['nullable', 'numeric', 'exists:hafas_operators,id'], 'originId' => ['required', 'exists:train_stations,ibnr'], 'originDeparturePlanned' => ['required', 'date'], 'destinationId' => ['required', 'exists:train_stations,ibnr'], @@ -50,8 +50,8 @@ public function createTrip(Request $request): HafasTripResource { $creator->category = HafasTravelType::from($validated['category']); $creator->lineName = $validated['lineName']; - $creator->journeyNumber = $validated['journey_number']; - $creator->operator = HafasOperator::find($validated['operator_id']); + $creator->journeyNumber = $validated['journeyNumber']; + $creator->operator = HafasOperator::find($validated['operatorId']); $creator->origin = TrainStation::where('ibnr', $validated['originId'])->firstOrFail(); $creator->originDeparturePlanned = Carbon::parse($validated['originDeparturePlanned']); $creator->destination = TrainStation::where('ibnr', $validated['destinationId'])->firstOrFail(); diff --git a/app/Http/Controllers/Frontend/Admin/TripController.php b/app/Http/Controllers/Frontend/Admin/TripController.php index 9978df404..875de8fd7 100644 --- a/app/Http/Controllers/Frontend/Admin/TripController.php +++ b/app/Http/Controllers/Frontend/Admin/TripController.php @@ -26,43 +26,4 @@ public function renderTrip(string $id): View { 'trip' => $trip ]); } - - public function createTrip(Request $request): RedirectResponse { - $validated = $request->validate([ - 'origin' => ['required', 'numeric', 'exists:train_stations,ibnr'], - 'departure' => ['required'], - 'destination' => ['required', 'numeric', 'exists:train_stations,ibnr'], - 'arrival' => ['required'], - 'operator_id' => ['nullable', 'numeric', 'exists:hafas_operators,id'], - 'category' => ['required', new Enum(HafasTravelType::class)], - 'number' => ['required', 'string'], - 'linename' => ['required', 'string'], - 'journey_number' => ['required', 'numeric'], - ]); - - $creator = new ManualTripCreator(); - - $creator->category = HafasTravelType::from($validated['category']); - $creator->lineName = $validated['linename']; - $creator->journeyNumber = $validated['journey_number']; - $creator->operator = HafasOperator::find($validated['operator_id']); - $creator->origin = TrainStation::where('ibnr', $validated['origin'])->firstOrFail(); - $creator->originDeparturePlanned = Carbon::parse(str_contains($validated['departure'], '+') && str_contains($validated['departure'], '-') - ? $validated['departure'] : $validated['departure'] . '+00:00'); - $creator->destination = TrainStation::where('ibnr', $validated['destination'])->firstOrFail(); - $creator->destinationArrivalPlanned = Carbon::parse(str_contains($validated['arrival'], '+') && str_contains($validated['arrival'], '-') - ? $validated['arrival'] : $validated['arrival'] . '+00:00'); - - $trip = $creator->createTrip(); - $creator->createOriginStopover(); - $creator->createDestinationStopover(); - $trip->refresh(); - - return redirect()->route('trains.trip', [ - 'tripID' => $trip->trip_id, - 'lineName' => $trip->linename, - 'start' => $trip->origin, - 'departure' => $trip->departure->toIso8601String(), - ]); - } } diff --git a/database/seeders/UsersTableSeeder.php b/database/seeders/UsersTableSeeder.php index bc7f3698a..df0e2a4d3 100644 --- a/database/seeders/UsersTableSeeder.php +++ b/database/seeders/UsersTableSeeder.php @@ -25,6 +25,7 @@ public function run(): void { 'password' => Hash::make('thisisnotasecurepassword123'), ]); $gertrud->assignRole('admin'); + $gertrud->assignRole('closed-beta'); User::factory() ->create([ diff --git a/resources/views/admin/trip/create.blade.php b/resources/views/admin/trip/create.blade.php index 7d8f8d66f..3d0b814de 100644 --- a/resources/views/admin/trip/create.blade.php +++ b/resources/views/admin/trip/create.blade.php @@ -11,70 +11,92 @@ It should be tested if the trip is created correctly and all data required for the trip is present, so no (500) errors occur. -
ToDo: Stopovers and some detailled information
+
ToDo: Stopovers and some detailed information
-
+ @csrf -
- - +
+
+
+ + +
+
+
+
+ + +
+
-
- - +
+
+
+ + +
+
+
+
+ + +
+
-
- - +
+
+
+ + +
+
+
+
+ + +
+
-
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - +
+
+
+ + +
+
+
+
+ + +
+