2016-11-28 17:06:04 -05:00
|
|
|
<?php
|
|
|
|
|
2016-11-28 18:08:54 -05:00
|
|
|
// retrieve album info
|
|
|
|
$app->get('/apiv1/music/album-info/:albumid', function($albumid) use($app) {
|
|
|
|
|
|
|
|
if (!ctype_digit($albumid)) {
|
|
|
|
echo 'Don\'t do that';
|
|
|
|
return;
|
|
|
|
}
|
2016-11-28 17:06:04 -05:00
|
|
|
|
|
|
|
$album = $app->album->where('id', $albumid)->first();
|
|
|
|
|
|
|
|
if ($album) {
|
|
|
|
echo json_encode($album);
|
|
|
|
} else {
|
2016-11-28 18:08:54 -05:00
|
|
|
$app->notFound();
|
2016-11-28 17:06:04 -05:00
|
|
|
}
|
|
|
|
|
2016-11-28 23:24:18 -05:00
|
|
|
})->name('apiv1.music.album-info');
|
|
|
|
|
|
|
|
// retrieve an album's songs
|
2016-11-28 23:25:25 -05:00
|
|
|
$app->get('/apiv1/music/album-songs/:albumid', function($albumid) use($app) {
|
2016-11-28 23:24:18 -05:00
|
|
|
|
|
|
|
if (!ctype_digit($albumid)) {
|
|
|
|
echo 'Don\'t do that';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$album = $app->album->where('id', $albumid)->first();
|
|
|
|
|
|
|
|
if ($album) {
|
2016-11-28 23:47:11 -05:00
|
|
|
$json = ['songs' => $album->songs];
|
2016-11-28 23:24:18 -05:00
|
|
|
echo json_encode($json);
|
|
|
|
} else {
|
|
|
|
$app->notFound();
|
|
|
|
}
|
|
|
|
|
2016-11-28 23:25:56 -05:00
|
|
|
})->name('apiv1.music.album-songs');
|