findMany($request->songs); $songs->each(fn ($song) => $this->authorize('download', $song)); // For a single episode, we'll just redirect to its original media to save time and bandwidth if ($songs->count() === 1 && $songs[0]->isEpisode()) { return response()->redirectTo($songs[0]->path); } $downloadablePath = $service->getDownloadablePath($repository->getMany($request->songs)); abort_unless((bool) $downloadablePath, Response::HTTP_BAD_REQUEST, 'Song or episode cannot be downloaded.'); return response()->download($downloadablePath); } }