2016-06-04 13:42:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API\Download;
|
|
|
|
|
|
|
|
use App\Http\Requests\API\Download\Request;
|
2018-08-29 06:15:11 +00:00
|
|
|
use App\Repositories\InteractionRepository;
|
2018-08-22 20:25:01 +00:00
|
|
|
use App\Services\DownloadService;
|
2016-06-04 13:42:12 +00:00
|
|
|
|
2018-12-09 21:24:43 +00:00
|
|
|
/**
|
|
|
|
* @group 6. Download
|
|
|
|
*/
|
2016-06-04 13:42:12 +00:00
|
|
|
class FavoritesController extends Controller
|
|
|
|
{
|
2018-08-29 06:15:11 +00:00
|
|
|
private $interactionRepository;
|
2018-08-22 20:25:01 +00:00
|
|
|
|
2018-08-29 06:15:11 +00:00
|
|
|
public function __construct(DownloadService $downloadService, InteractionRepository $interactionRepository)
|
2018-08-22 20:25:01 +00:00
|
|
|
{
|
|
|
|
parent::__construct($downloadService);
|
2018-08-29 06:15:11 +00:00
|
|
|
$this->interactionRepository = $interactionRepository;
|
2018-08-22 20:25:01 +00:00
|
|
|
}
|
|
|
|
|
2016-06-04 13:42:12 +00:00
|
|
|
/**
|
2020-04-12 08:18:17 +00:00
|
|
|
* Download all songs favorite'd by the current user
|
2018-12-09 21:24:43 +00:00
|
|
|
*
|
|
|
|
* @response []
|
2016-06-04 13:42:12 +00:00
|
|
|
*/
|
2018-08-18 11:51:52 +00:00
|
|
|
public function show(Request $request)
|
2016-06-04 13:42:12 +00:00
|
|
|
{
|
2018-08-29 06:15:11 +00:00
|
|
|
$songs = $this->interactionRepository->getUserFavorites($request->user());
|
2018-08-18 11:51:52 +00:00
|
|
|
|
|
|
|
return response()->download($this->downloadService->from($songs));
|
2016-06-04 13:42:12 +00:00
|
|
|
}
|
|
|
|
}
|