validate([ 'url' => ['required', 'url'], ]); $text = $this->translationService->fetchFromUrl($request->input('url')); if ($text === null) { return response()->json([ 'message' => 'Konnte Text nicht abrufen', ], 422); } return response()->json([ 'text' => $text, ]); } /** * Übersetzungstext für einen Song importieren. * * Verteilt den Text zeilenweise auf die Slides des Songs. */ public function import(int $songId, Request $request): JsonResponse { $song = Song::find($songId); if (! $song) { return response()->json([ 'message' => 'Song nicht gefunden', ], 404); } $request->validate([ 'text' => ['required', 'string'], ]); $this->translationService->importTranslation($song, $request->input('text')); return response()->json([ 'message' => 'Übersetzung erfolgreich importiert', ]); } /** * Übersetzung eines Songs komplett entfernen. */ public function destroy(int $songId): JsonResponse { $song = Song::find($songId); if (! $song) { return response()->json([ 'message' => 'Song nicht gefunden', ], 404); } $this->translationService->removeTranslation($song); return response()->json([ 'message' => 'Übersetzung entfernt', ]); } }