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

33 lines
833 B
PHP

<?php
namespace App\Http\Controllers\Download;
use App\Http\Requests\Download\Request;
use App\Repositories\InteractionRepository;
use App\Services\DownloadService;
/**
* @group 6. Download
*/
class FavoritesController extends Controller
{
private $interactionRepository;
public function __construct(DownloadService $downloadService, InteractionRepository $interactionRepository)
{
parent::__construct($downloadService);
$this->interactionRepository = $interactionRepository;
}
/**
* Download all songs favorite'd by the current user
*
* @response []
*/
public function show(Request $request)
{
$songs = $this->interactionRepository->getUserFavorites($request->user());
return response()->download($this->downloadService->from($songs));
}
}