validate([ 'file' => ['required', 'file', 'max:51200'], ]); $file = $request->file('file'); $extension = strtolower($file->getClientOriginalExtension()); if (! in_array($extension, ['pro', 'zip'])) { return response()->json([ 'message' => 'Nur .pro und .zip Dateien sind erlaubt.', ], 422); } try { $service = new ProImportService(); $songs = $service->import($file); return response()->json([ 'message' => count($songs) === 1 ? "Song \"{$songs[0]->title}\" erfolgreich importiert." : count($songs) . ' Songs erfolgreich importiert.', 'songs' => collect($songs)->map(fn (Song $song) => [ 'id' => $song->id, 'title' => $song->title, 'ccli_id' => $song->ccli_id, ]), ]); } catch (\InvalidArgumentException $e) { return response()->json(['message' => $e->getMessage()], 422); } catch (\RuntimeException $e) { return response()->json(['message' => $e->getMessage()], 422); } } public function downloadPro(Song $song): JsonResponse { throw new ProParserNotImplementedException(); } }