public function getProfile($slug) { $user = User::whereSlug($slug)->whereNull('disabled_at')->first(); if (!$user) { App::abort('404'); } return View::make('artists.profile'); }
public function getShow($slug) { $user = User::whereSlug($slug)->whereNull('disabled_at')->userDetails()->with(['comments' => function ($query) { $query->with('user'); }])->first(); if (!$user) { App::abort(404); } $trackQuery = Track::summary()->published()->explicitFilter()->listed()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20); $latestTracks = []; foreach ($trackQuery->get() as $track) { $latestTracks[] = Track::mapPublicTrackSummary($track); } $comments = []; foreach ($user->comments as $comment) { $comments[] = Comment::mapPublic($comment); } $userData = ['is_following' => false]; if ($user->users->count()) { $userRow = $user->users[0]; $userData = ['is_following' => (bool) $userRow->is_followed]; } return Response::json(['artist' => ['id' => (int) $user->id, 'name' => $user->display_name, 'slug' => $user->slug, 'is_archived' => (bool) $user->is_archived, 'avatars' => ['small' => $user->getAvatarUrl(Image::SMALL), 'normal' => $user->getAvatarUrl(Image::NORMAL)], 'created_at' => $user->created_at, 'followers' => [], 'following' => [], 'latest_tracks' => $latestTracks, 'comments' => $comments, 'bio' => $user->bio, 'mlpforums_username' => $user->username, 'message_url' => $user->message_url, 'user_data' => $userData]], 200); }