2016-06-04 12:29:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API\Download;
|
|
|
|
|
|
|
|
use App\Models\Playlist;
|
|
|
|
use Download;
|
2017-06-04 01:30:45 +00:00
|
|
|
use Exception;
|
|
|
|
use Illuminate\Auth\Access\AuthorizationException;
|
|
|
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
2016-06-04 12:29:23 +00:00
|
|
|
|
|
|
|
class PlaylistController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Download all songs in a playlist.
|
|
|
|
*
|
|
|
|
* @param Playlist $playlist
|
|
|
|
*
|
2017-06-04 01:30:45 +00:00
|
|
|
* @throws AuthorizationException
|
|
|
|
* @throws Exception
|
2016-08-03 10:42:39 +00:00
|
|
|
*
|
2017-06-04 01:30:45 +00:00
|
|
|
* @return BinaryFileResponse
|
2016-06-04 12:29:23 +00:00
|
|
|
*/
|
2016-08-03 10:42:11 +00:00
|
|
|
public function download(Playlist $playlist)
|
2016-06-04 12:29:23 +00:00
|
|
|
{
|
2016-06-04 13:29:45 +00:00
|
|
|
$this->authorize('owner', $playlist);
|
|
|
|
|
2016-06-04 12:29:23 +00:00
|
|
|
return response()->download(Download::from($playlist));
|
|
|
|
}
|
|
|
|
}
|