koel/app/Http/Controllers/API/Download/FavoritesController.php
2018-08-22 22:25:23 +02:00

33 lines
879 B
PHP

<?php
namespace App\Http\Controllers\API\Download;
use App\Http\Requests\API\Download\Request;
use App\Services\DownloadService;
use App\Services\InteractionService;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class FavoritesController extends Controller
{
private $interactionService;
public function __construct(DownloadService $downloadService, InteractionService $interactionService)
{
parent::__construct($downloadService);
$this->interactionService = $interactionService;
}
/**
* Download all songs in a playlist.
*
* @param Request $request
*
* @return BinaryFileResponse
*/
public function show(Request $request)
{
$songs = $this->interactionService->getUserFavorites($request->user());
return response()->download($this->downloadService->from($songs));
}
}