Esempio n. 1
0
 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'));
 }
Esempio n. 2
0
 public function search()
 {
     $current_user = Auth::user();
     $params = [];
     if (is_null($current_user)) {
         $params = ['page' => Request::input('page')];
     } else {
         $params = ['query' => Request::input('q'), 'mode' => Request::input('m'), 'status' => Request::input('s'), 'genre' => Request::input('g'), 'language' => Request::input('l'), 'extra' => array_filter(explode('-', Request::input('e')), 'strlen'), 'rank' => array_filter(explode('-', Request::input('r')), 'strlen'), 'page' => Request::input('page'), 'sort' => explode('_', Request::input('sort'))];
         if (!$current_user->isSupporter()) {
             unset($params['rank']);
         }
     }
     $params = array_filter($params, function ($v, $k) {
         if (is_array($v)) {
             return !empty($v);
         } else {
             return presence($v) !== null;
         }
     }, ARRAY_FILTER_USE_BOTH);
     $beatmaps = BeatmapSet::search($params);
     return fractal_collection_array($beatmaps, new BeatmapSetTransformer(), 'difficulties');
 }
Esempio n. 3
0
 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'));
 }
Esempio n. 4
0
 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'));
 }
Esempio n. 5
0
 public function includeAllScores(User $user)
 {
     return $this->item($user, function ($user) {
         $all = [];
         foreach (array_keys(Beatmap::modes()) as $mode) {
             $scores = $user->scores($mode, true)->default()->with('beatmapSet', 'beatmap')->get();
             $all[$mode] = fractal_collection_array($scores, new ScoreTransformer(), 'beatmap,beatmapSet');
         }
         return $all;
     });
 }