mirror of
https://github.com/koel/koel
synced 2024-12-22 02:23:14 +00:00
33 lines
924 B
PHP
33 lines
924 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Download;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Playlist;
|
|
use App\Models\User;
|
|
use App\Repositories\SongRepository;
|
|
use App\Services\DownloadService;
|
|
use App\Services\SmartPlaylistService;
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
|
|
class DownloadPlaylistController extends Controller
|
|
{
|
|
/** @param User $user */
|
|
public function __invoke(
|
|
Playlist $playlist,
|
|
SongRepository $repository,
|
|
SmartPlaylistService $smartPlaylistService,
|
|
DownloadService $download,
|
|
Authenticatable $user
|
|
) {
|
|
$this->authorize('download', $playlist);
|
|
|
|
return response()->download(
|
|
$download->from(
|
|
$playlist->is_smart
|
|
? $smartPlaylistService->getSongs($playlist, $user)
|
|
: $repository->getByStandardPlaylist($playlist, $user)
|
|
)
|
|
);
|
|
}
|
|
}
|