validate([ 'origin' => 'required|string|max:200', 'destination' => 'required|string|max:200', 'mode' => 'sometimes|string|in:driving,walking,bicycling,transit', ]); $route = $routes->route( $request->string('origin')->toString(), $request->string('destination')->toString(), $request->string('mode', 'driving')->toString(), ); if (! $route) { return response()->json(['error' => 'Keine Route gefunden'], 404); } return response()->json($route); } }