Adding two of the mobile endpoints back, hopefully the data matches

This commit is contained in:
Adam Lavin 2013-11-28 13:32:33 +00:00
parent 3815016f3c
commit 1b6032e9e3
2 changed files with 48 additions and 1 deletions

View file

@ -0,0 +1,40 @@
<?php namespace Api\Mobile;
use Entities\Track;
class TracksController extends Controller
{
public function latest()
{
$tracks = Track::summary()
->userDetails()
->listed()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user')->take(10);
$json = [
'total_tracks' => $tracks->count(),
'tracks' => $tracks->toArray()
];
return Response::json($json, 200);
}
public function popular()
{
$tracks = Track::popular(10)
->userDetails()
->listed()
->explicitFilter()
->published()
->with('user', 'genre', 'cover', 'album', 'album.user')->take(10);
$json = [
'total_tracks' => $tracks->count(),
'tracks' => $tracks->toArray()
];
return Response::json($json, 200);
}
}

View file

@ -151,4 +151,11 @@
Route::get('{slug}/content', 'ArtistsController@getProfile');
Route::get('{slug}/favourites', 'ArtistsController@getProfile');
Route::get('/', 'HomeController@getIndex');
Route::get('/', 'HomeController@getIndex');
Route::group(['domain' => 'api.pony.fm'], function() {
Route::get('tracks/latest', ['uses' => 'Api\Mobile\TracksController@latest']);
Route::get('tracks/popular', [ 'uses' => 'Api\Mobile\TracksController@popular']);
/* Route::get('tracks/id', [ 'uses' => 'Api\Mobile\TracksController@track']);
Route::get('user', ['uses' => 'Api\Mobile\UserController@user']);*/
});