public function show($id) { $user = User::lookup($id); if ($user === null || !$user->hasProfile()) { abort(404); } $userArray = fractal_item_array($user, new UserTransformer(), 'allStatistics,page,recentAchievements,recentActivities,recentlyReceivedKudosu'); return view('users.show', compact('user', 'userArray')); }
public function includeAllStatistics(User $user) { return $this->item($user, function ($user) { $all = []; foreach ($user->statisticsAll() as $mode => $statistics) { $all[$mode] = fractal_item_array($statistics, new UserStatisticsTransformer()); } return $all; }); }
public function show($id) { $user = User::lookup($id); if ($user === null || !$user->hasProfile()) { abort(404); } $achievements = fractal_collection_array(Achievement::achievable()->orderBy('grouping')->orderBy('ordering')->orderBy('progression')->get(), new AchievementTransformer()); $userArray = fractal_item_array($user, new UserTransformer(), implode(',', ['allAchievements', 'allScores', 'allScoresBest', 'allScoresFirst', 'allStatistics', 'beatmapPlaycounts', 'page', 'recentActivities', 'recentlyReceivedKudosu', 'rankedAndApprovedBeatmapSets.difficulties', 'favouriteBeatmapSets.difficulties'])); return view('users.show', compact('user', 'userArray', 'achievements')); }
public function show($id) { $forum = Forum::with('subForums')->findOrFail($id); $this->authorizeView($forum); $cover = fractal_item_array($forum->cover()->firstOrNew([]), new ForumCoverTransformer()); $pinnedTopics = $forum->topics()->pinned()->orderBy('topic_type', 'desc')->recent()->get(); $topics = $forum->topics()->normal()->recent()->paginate(15); $topicReadStatus = TopicTrack::readStatus(Auth::user(), $pinnedTopics, $topics); return view('forum.forums.show', compact('forum', 'topics', 'pinnedTopics', 'topicReadStatus', 'cover')); }
public function includeAllRankHistories(User $user) { return $this->item($user, function ($user) { $all = []; foreach ($user->rankHistories as $history) { $modeStr = Beatmap::modeStr($history->mode); $all[$modeStr] = fractal_item_array($history, new RankHistoryTransformer()); } return $all; }); }
public function update($id) { $cover = ForumCover::findOrFail($id); if (Request::hasFile('cover_file') === true) { try { $cover = $cover->updateFile(Request::file('cover_file')->getRealPath(), Auth::user()); } catch (ImageProcessorException $e) { return error_popup($e->getMessage()); } } return fractal_item_array($cover, new ForumCoverTransformer()); }
public function updateProfileCover() { if (Request::hasFile('cover_file') && !Auth::user()->osu_subscriber) { abort(403); } $customization = Auth::user()->profileCustomization()->firstOrNew([]); $customization->setCover($errors, Request::input('cover_id'), Request::file('cover_file')); if (count($errors) === 0) { return fractal_item_array(Auth::user(), new UserTransformer()); } else { return error_popup(implode(',', $errors)); } }
public function show($id) { $postStartId = Request::input('start'); $postEndId = get_int(Request::input('end')); $nthPost = get_int(Request::input('n')); $skipLayout = Request::input('skip_layout') === '1'; $jumpTo = null; $topic = Topic::with('forum.cover')->findOrFail($id); $this->authorizeView($topic->forum); $posts = $topic->posts(); if ($postStartId === 'unread') { $postStartId = Post::lastUnreadByUser($topic, Auth::user()); } else { $postStartId = get_int($postStartId); } if ($nthPost !== null) { $post = $topic->nthPost($nthPost); if ($post) { $postStartId = $post->post_id; } } if (!$skipLayout) { foreach ([$postStartId, $postEndId, 0] as $jumpPoint) { if ($jumpPoint === null) { continue; } $jumpTo = $jumpPoint; break; } } if ($postStartId !== null && !$skipLayout) { // move starting post up by ten to avoid hitting // page autoloader right after loading the page. $postPosition = $topic->postPosition($postStartId); $post = $topic->nthPost($postPosition - 10); $postStartId = $post->post_id; } if ($postStartId !== null) { $posts = $posts->where('post_id', '>=', $postStartId); } elseif ($postEndId !== null) { $posts = $posts->where('post_id', '<=', $postEndId)->orderBy('post_id', 'desc'); } $posts = $posts->take(20)->with('user.rank')->with('user.country')->with('user.supports')->get()->sortBy(function ($p) { return $p->post_id; }); if ($posts->count() === 0) { abort($skipLayout ? 204 : 404); } $postsPosition = $topic->postsPosition($posts); Event::fire(new TopicWasViewed($topic, $posts->last(), Auth::user())); $template = $skipLayout ? '_posts' : 'show'; $cover = fractal_item_array($topic->cover()->firstOrNew([]), new TopicCoverTransformer()); return view("forum.topics.{$template}", compact('topic', 'posts', 'postsPosition', 'jumpTo', 'cover')); }
public function defaultJson() { return fractal_item_array($this, new UserTransformer(), 'defaultStatistics'); }
public function show($id) { if (is_numeric($id)) { $user = User::find($id); } else { $user = User::where('username', $id)->orWhere('username_clean', $id)->first(); } if ($user === null || !$user->hasProfile()) { abort(404); } if ($user->userPage !== null) { $userPage = ["html" => $user->userPage->bodyHTML, "raw" => $user->userPage->bodyRaw]; } else { $userPage = ["html" => "", "raw" => ""]; } $allStats = []; foreach ($user->statisticsAll() as $mode => $stats) { $allStats[$mode] = fractal_item_array($stats, new UserStatisticsTransformer()); } $recentAchievements = fractal_collection_array($user->achievements()->with("achievement")->orderBy("date", "desc")->limit(8)->get(), new UserAchievementTransformer()); $userArray = fractal_item_array($user, new UserTransformer()); $achievementsCounts = ["total" => Achievement::count(), "user" => $user->achievements()->count()]; return view('users.show', compact('user', 'mode', 'allStats', 'userPage', 'userArray', 'recentAchievements', 'achievementsCounts')); }
public function show($id) { if (is_numeric($id)) { $user = User::find($id); } else { $user = User::where('username', $id)->orWhere('username_clean', $id)->first(); } if ($user === null || !$user->hasProfile()) { abort(404); } if ($user->userPage !== null) { $userPage = ['html' => $user->userPage->bodyHTML, 'raw' => $user->userPage->bodyRaw]; } else { $userPage = ['html' => '', 'raw' => '']; } $allStats = []; foreach ($user->statisticsAll() as $mode => $stats) { $allStats[$mode] = fractal_item_array($stats, new UserStatisticsTransformer()); } $recentAchievements = fractal_collection_array($user->achievements()->with('achievement')->orderBy('date', 'desc')->limit(8)->get(), new UserAchievementTransformer()); $recentActivities = fractal_collection_array($user->events()->recent()->get(), new EventTransformer()); $recentlyReceivedKudosu = fractal_collection_array($user->receivedKudosu()->withPost()->with('post', 'post.topic', 'giver')->orderBy('exchange_id', 'desc')->limit(15)->get(), new KudosuHistoryTransformer()); $userArray = fractal_item_array($user, new UserTransformer()); return view('users.show', compact('user', 'mode', 'allStats', 'userPage', 'userArray', 'recentAchievements', 'recentActivities', 'recentlyReceivedKudosu')); }