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

25 lines
562 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;
2017-06-04 01:30:45 +00:00
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
* @return BinaryFileResponse
2016-06-02 17:53:26 +00:00
*/
2018-08-18 11:51:52 +00:00
public function show(SongRequest $request)
2016-06-02 17:53:26 +00:00
{
$songs = Song::whereIn('id', $request->songs)->get();
2018-08-18 11:51:52 +00:00
return response()->download($this->downloadService->from($songs));
2016-06-02 17:53:26 +00:00
}
}