koel/app/Http/Controllers/Download/DownloadSongsController.php

20 lines
614 B
PHP
Raw Normal View History

2024-01-03 17:02:18 +00:00
<?php
namespace App\Http\Controllers\Download;
use App\Http\Controllers\Controller;
use App\Http\Requests\Download\DownloadSongsRequest;
use App\Repositories\SongRepository;
use App\Services\DownloadService;
class DownloadSongsController extends Controller
{
public function __invoke(DownloadSongsRequest $request, DownloadService $download, SongRepository $repository)
{
2024-01-07 12:43:10 +00:00
$songs = $repository->getMany($request->songs);
$songs->each(fn ($song) => $this->authorize('download', $song));
2024-01-03 17:02:18 +00:00
return response()->download($download->from($repository->getMany($request->songs)));
}
}