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-01 10:57:08 +02:00
|
|
|
$query = Track::summary()->with(['genre', 'user', 'cover'])->details()->whereNotNull('published_at')->orderBy('published_at', 'desc')->take(30);
|
2013-07-28 23:51:35 +02:00
|
|
|
if (!Auth::check() || !Auth::user()->can_see_explicit_content)
|
|
|
|
$query->whereIsExplicit(false);
|
|
|
|
|
|
|
|
$tracks = [];
|
|
|
|
|
|
|
|
foreach ($query->get() as $track) {
|
2013-08-01 10:57:08 +02:00
|
|
|
$tracks[] = Track::mapPublicTrackSummary($track);
|
2013-07-28 23:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Response::json([
|
|
|
|
'recent_tracks' => $tracks,
|
|
|
|
'popular_tracks' => $tracks], 200);
|
|
|
|
}
|
|
|
|
}
|