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

29 lines
743 B
PHP
Raw Normal View History

2016-06-04 13:42:12 +00:00
<?php
namespace App\Http\Controllers\API\Download;
use App\Http\Requests\API\Download\Request;
2018-08-22 20:25:01 +00:00
use App\Services\DownloadService;
use App\Services\InteractionService;
2016-06-04 13:42:12 +00:00
class FavoritesController extends Controller
{
2018-08-22 20:25:01 +00:00
private $interactionService;
public function __construct(DownloadService $downloadService, InteractionService $interactionService)
{
parent::__construct($downloadService);
$this->interactionService = $interactionService;
}
2016-06-04 13:42:12 +00:00
/**
* Download all songs in a playlist.
*/
2018-08-18 11:51:52 +00:00
public function show(Request $request)
2016-06-04 13:42:12 +00:00
{
2018-08-22 20:25:01 +00:00
$songs = $this->interactionService->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
}
}