koel/app/Http/Controllers/API/Download/FavoritesController.php
Phan An ab4f2210d1
API doc (#872)
* Add the API documentation

* Apply fixes from StyleCI (#871)
2018-12-09 22:24:43 +01:00

33 lines
842 B
PHP

<?php
namespace App\Http\Controllers\API\Download;
use App\Http\Requests\API\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));
}
}