1 | <?php |
||
2 | |||
3 | namespace App\Http\Controllers\API; |
||
4 | |||
5 | use App\Http\Requests\API\ViewSongOnITunesRequest; |
||
6 | use App\Models\Album; |
||
7 | use App\Services\iTunesService; |
||
8 | use Illuminate\Http\RedirectResponse; |
||
9 | |||
10 | class iTunesController extends Controller |
||
11 | { |
||
12 | private $iTunesService; |
||
13 | |||
14 | public function __construct(iTunesService $iTunesService) |
||
15 | { |
||
16 | $this->iTunesService = $iTunesService; |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * View a song on iTunes store. |
||
21 | * |
||
22 | * @return RedirectResponse |
||
23 | */ |
||
24 | public function viewSong(ViewSongOnITunesRequest $request, Album $album) |
||
25 | { |
||
26 | $url = $this->iTunesService->getTrackUrl($request->q, $album->name, $album->artist->name); |
||
27 | abort_unless($url, 404, "Koel can't find such a song on iTunes Store."); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
28 | |||
29 | return redirect($url); |
||
30 | } |
||
31 | } |
||
32 |