2013-07-28 23:51:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Api\Web;
|
|
|
|
|
|
|
|
use Commands\DeleteTrackCommand;
|
|
|
|
use Commands\EditTrackCommand;
|
|
|
|
use Commands\UploadTrackCommand;
|
|
|
|
use Cover;
|
|
|
|
use Entities\Image;
|
|
|
|
use Entities\Track;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\Input;
|
|
|
|
use Illuminate\Support\Facades\Response;
|
|
|
|
|
|
|
|
class DashboardController extends \ApiControllerBase {
|
|
|
|
public function getIndex() {
|
2013-08-29 05:19:24 +02:00
|
|
|
$recentQuery = Track::summary()
|
|
|
|
->with(['genre', 'user', 'cover', 'user.avatar'])
|
|
|
|
->userDetails()
|
|
|
|
->explicitFilter()
|
|
|
|
->published()
|
|
|
|
->orderBy('published_at', 'desc')
|
2013-09-01 04:59:12 +02:00
|
|
|
->take(20);
|
2013-07-28 23:51:35 +02:00
|
|
|
|
2013-08-29 05:19:24 +02:00
|
|
|
$recentTracks = [];
|
2013-07-28 23:51:35 +02:00
|
|
|
|
2013-08-29 05:19:24 +02:00
|
|
|
foreach ($recentQuery->get() as $track) {
|
|
|
|
$recentTracks[] = Track::mapPublicTrackSummary($track);
|
2013-07-28 23:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json([
|
2013-08-29 05:19:24 +02:00
|
|
|
'recent_tracks' => $recentTracks,
|
|
|
|
'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content)], 200);
|
2013-07-28 23:51:35 +02:00
|
|
|
}
|
|
|
|
}
|