mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-29 08:07:59 +01:00
T366: Explicitly return ints and boolean values as such in the website API.
This commit is contained in:
parent
b66ec54221
commit
47b172ccc4
4 changed files with 41 additions and 41 deletions
|
@ -119,16 +119,16 @@
|
||||||
if ($user->users->count()) {
|
if ($user->users->count()) {
|
||||||
$userRow = $user->users[0];
|
$userRow = $user->users[0];
|
||||||
$userData = [
|
$userData = [
|
||||||
'is_following' => $userRow->is_followed
|
'is_following' => (bool) $userRow->is_followed
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json([
|
return Response::json([
|
||||||
'artist' => [
|
'artist' => [
|
||||||
'id' => $user->id,
|
'id' => (int) $user->id,
|
||||||
'name' => $user->display_name,
|
'name' => $user->display_name,
|
||||||
'slug' => $user->slug,
|
'slug' => $user->slug,
|
||||||
'is_archived' => $user->is_archived,
|
'is_archived' => (bool) $user->is_archived,
|
||||||
'avatars' => [
|
'avatars' => [
|
||||||
'small' => $user->getAvatarUrl(Image::SMALL),
|
'small' => $user->getAvatarUrl(Image::SMALL),
|
||||||
'normal' => $user->getAvatarUrl(Image::NORMAL)
|
'normal' => $user->getAvatarUrl(Image::NORMAL)
|
||||||
|
|
|
@ -112,24 +112,24 @@
|
||||||
$userRow = $album->users[0];
|
$userRow = $album->users[0];
|
||||||
$userData = [
|
$userData = [
|
||||||
'stats' => [
|
'stats' => [
|
||||||
'views' => $userRow->view_count,
|
'views' => (int) $userRow->view_count,
|
||||||
'downloads' => $userRow->download_count,
|
'downloads' => (int) $userRow->download_count,
|
||||||
],
|
],
|
||||||
'is_favourited' => $userRow->is_favourited
|
'is_favourited' => (bool) $userRow->is_favourited
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $album->id,
|
'id' => (int) $album->id,
|
||||||
'track_count' => $album->track_count,
|
'track_count' => (int) $album->track_count,
|
||||||
'title' => $album->title,
|
'title' => $album->title,
|
||||||
'slug' => $album->slug,
|
'slug' => $album->slug,
|
||||||
'created_at' => $album->created_at,
|
'created_at' => $album->created_at,
|
||||||
'stats' => [
|
'stats' => [
|
||||||
'views' => $album->view_count,
|
'views' => (int) $album->view_count,
|
||||||
'downloads' => $album->download_count,
|
'downloads' => (int) $album->download_count,
|
||||||
'comments' => $album->comment_count,
|
'comments' => (int) $album->comment_count,
|
||||||
'favourites' => $album->favourite_count
|
'favourites' => (int) $album->favourite_count
|
||||||
],
|
],
|
||||||
'covers' => [
|
'covers' => [
|
||||||
'small' => $album->getCoverUrl(Image::SMALL),
|
'small' => $album->getCoverUrl(Image::SMALL),
|
||||||
|
@ -137,7 +137,7 @@
|
||||||
],
|
],
|
||||||
'url' => $album->url,
|
'url' => $album->url,
|
||||||
'user' => [
|
'user' => [
|
||||||
'id' => $album->user->id,
|
'id' => (int) $album->user->id,
|
||||||
'name' => $album->user->display_name,
|
'name' => $album->user->display_name,
|
||||||
'url' => $album->user->url,
|
'url' => $album->user->url,
|
||||||
],
|
],
|
||||||
|
|
|
@ -75,25 +75,25 @@
|
||||||
$userRow = $playlist->users[0];
|
$userRow = $playlist->users[0];
|
||||||
$userData = [
|
$userData = [
|
||||||
'stats' => [
|
'stats' => [
|
||||||
'views' => $userRow->view_count,
|
'views' => (int) $userRow->view_count,
|
||||||
'downloads' => $userRow->download_count,
|
'downloads' => (int) $userRow->download_count,
|
||||||
],
|
],
|
||||||
'is_favourited' => $userRow->is_favourited
|
'is_favourited' => (bool) $userRow->is_favourited
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $playlist->id,
|
'id' => (int) $playlist->id,
|
||||||
'track_count' => $playlist->track_count,
|
'track_count' => $playlist->track_count,
|
||||||
'title' => $playlist->title,
|
'title' => $playlist->title,
|
||||||
'slug' => $playlist->slug,
|
'slug' => $playlist->slug,
|
||||||
'created_at' => $playlist->created_at,
|
'created_at' => $playlist->created_at,
|
||||||
'is_public' => $playlist->is_public,
|
'is_public' => (bool) $playlist->is_public,
|
||||||
'stats' => [
|
'stats' => [
|
||||||
'views' => $playlist->view_count,
|
'views' => (int) $playlist->view_count,
|
||||||
'downloads' => $playlist->download_count,
|
'downloads' => (int) $playlist->download_count,
|
||||||
'comments' => $playlist->comment_count,
|
'comments' => (int) $playlist->comment_count,
|
||||||
'favourites' => $playlist->favourite_count
|
'favourites' => (int) $playlist->favourite_count
|
||||||
],
|
],
|
||||||
'covers' => [
|
'covers' => [
|
||||||
'small' => $playlist->getCoverUrl(Image::SMALL),
|
'small' => $playlist->getCoverUrl(Image::SMALL),
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
],
|
],
|
||||||
'url' => $playlist->url,
|
'url' => $playlist->url,
|
||||||
'user' => [
|
'user' => [
|
||||||
'id' => $playlist->user->id,
|
'id' => (int) $playlist->user->id,
|
||||||
'name' => $playlist->user->display_name,
|
'name' => $playlist->user->display_name,
|
||||||
'url' => $playlist->user->url,
|
'url' => $playlist->user->url,
|
||||||
],
|
],
|
||||||
|
|
|
@ -163,41 +163,41 @@
|
||||||
$userRow = $track->users[0];
|
$userRow = $track->users[0];
|
||||||
$userData = [
|
$userData = [
|
||||||
'stats' => [
|
'stats' => [
|
||||||
'views' => $userRow->view_count,
|
'views' => (int) $userRow->view_count,
|
||||||
'plays' => $userRow->play_count,
|
'plays' => (int) $userRow->play_count,
|
||||||
'downloads' => $userRow->download_count,
|
'downloads' => $userRow->download_count,
|
||||||
],
|
],
|
||||||
'is_favourited' => $userRow->is_favourited
|
'is_favourited' => (bool) $userRow->is_favourited
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $track->id,
|
'id' => (int) $track->id,
|
||||||
'title' => $track->title,
|
'title' => $track->title,
|
||||||
'user' => [
|
'user' => [
|
||||||
'id' => $track->user->id,
|
'id' => (int) $track->user->id,
|
||||||
'name' => $track->user->display_name,
|
'name' => $track->user->display_name,
|
||||||
'url' => $track->user->url
|
'url' => $track->user->url
|
||||||
],
|
],
|
||||||
'stats' => [
|
'stats' => [
|
||||||
'views' => $track->view_count,
|
'views' => (int) $track->view_count,
|
||||||
'plays' => $track->play_count,
|
'plays' => (int) $track->play_count,
|
||||||
'downloads' => $track->download_count,
|
'downloads' => (int) $track->download_count,
|
||||||
'comments' => $track->comment_count,
|
'comments' => (int) $track->comment_count,
|
||||||
'favourites' => $track->favourite_count
|
'favourites' => (int) $track->favourite_count
|
||||||
],
|
],
|
||||||
'url' => $track->url,
|
'url' => $track->url,
|
||||||
'slug' => $track->slug,
|
'slug' => $track->slug,
|
||||||
'is_vocal' => $track->is_vocal,
|
'is_vocal' => (bool) $track->is_vocal,
|
||||||
'is_explicit' => $track->is_explicit,
|
'is_explicit' => (bool) $track->is_explicit,
|
||||||
'is_downloadable' => $track->is_downloadable,
|
'is_downloadable' => (bool) $track->is_downloadable,
|
||||||
'is_published' => $track->isPublished(),
|
'is_published' => (bool) $track->isPublished(),
|
||||||
'published_at' => $track->published_at,
|
'published_at' => $track->published_at,
|
||||||
'duration' => $track->duration,
|
'duration' => $track->duration,
|
||||||
'genre' => $track->genre != null
|
'genre' => $track->genre != null
|
||||||
?
|
?
|
||||||
[
|
[
|
||||||
'id' => $track->genre->id,
|
'id' => (int) $track->genre->id,
|
||||||
'slug' => $track->genre->slug,
|
'slug' => $track->genre->slug,
|
||||||
'name' => $track->genre->name
|
'name' => $track->genre->name
|
||||||
] : null,
|
] : null,
|
||||||
|
|
Loading…
Reference in a new issue