koel/app/Http/Controllers/API/Download/SongController.php
2017-06-04 02:30:45 +01:00

28 lines
613 B
PHP

<?php
namespace App\Http\Controllers\API\Download;
use App\Http\Requests\API\Download\SongRequest;
use App\Models\Song;
use Download;
use Exception;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class SongController extends Controller
{
/**
* Download a song or multiple songs.
*
* @param SongRequest $request
*
* @throws Exception
*
* @return BinaryFileResponse
*/
public function download(SongRequest $request)
{
$songs = Song::whereIn('id', $request->songs)->get();
return response()->download(Download::from($songs));
}
}