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

29 lines
613 B
PHP
Raw Normal View History

2016-06-02 17:53:26 +00:00
<?php
namespace App\Http\Controllers\API\Download;
use App\Http\Requests\API\Download\SongRequest;
use App\Models\Song;
use Download;
2017-06-04 01:30:45 +00:00
use Exception;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
2016-06-02 17:53:26 +00:00
class SongController extends Controller
{
/**
* Download a song or multiple songs.
*
2016-06-04 17:10:29 +00:00
* @param SongRequest $request
2016-06-02 17:53:26 +00:00
*
2017-06-04 01:30:45 +00:00
* @throws Exception
2016-08-03 10:42:39 +00:00
*
2017-06-04 01:30:45 +00:00
* @return BinaryFileResponse
2016-06-02 17:53:26 +00:00
*/
public function download(SongRequest $request)
{
$songs = Song::whereIn('id', $request->songs)->get();
return response()->download(Download::from($songs));
}
}