public function getModeAttribute($value) { if (!present($value)) { return; } return Beatmap::modeStr((int) $value); }
public static function getClass($modeInt) { $modeStr = Beatmap::modeStr($modeInt); if ($modeStr !== null) { $klass = get_class_namespace(static::class) . '\\' . studly_case($modeStr); return new $klass(); } }
public function includeAllRankHistories(User $user) { return $this->item($user, function ($user) { $all = []; foreach ($user->rankHistories as $history) { $modeStr = Beatmap::modeStr($history->mode); $all[$modeStr] = json_item($history, new RankHistoryTransformer()); } return $all; }); }
public function getUser() { $id = Request::input('u'); $mode = Beatmap::modeStr(intval(Request::input('m', 0))); $type = Request::input('type'); $event_days = min(31, (int) Request::input('event_days', 1)); if ($mode === null) { return Response::json([]); } $user = User::lookup($id, $type); if (!$user) { return Response::json([]); } $stats = json_item($user->statistics($mode, true)->first(), new StatisticsTransformer()); $events = json_collection($user->events()->where('date', '>', Carbon::now()->addDays(-$event_days))->orderBy('event_id', 'desc')->get(), new EventTransformer()); $user = json_item($user, new UserTransformer()); $combined = array_merge($user, $stats, ['events' => $events]); return Response::json([$combined]); }
public function scores($id) { $beatmap = Beatmap::findOrFail($id); $mode = Request::input('mode', Beatmap::modeStr($beatmap->playmode)); $mods = Request::input('enabledMods'); $type = Request::input('type', 'global'); $user = Auth::user(); if (!is_array($mods)) { $mods = []; } if ($type !== 'global' || !empty($mods)) { if ($user === null || !$user->isSupporter()) { return error_popup(trans('errors.supporter_only')); } } try { $query = $beatmap->scoresBest($mode)->defaultListing()->with('user'); } catch (\InvalidArgumentException $ex) { return error_popup($ex->getMessage()); } $query->withMods($mods); switch ($type) { case 'country': $query->fromCountry($user->country_acronym); break; case 'friend': $query->friendsOf($user); break; } $scoresList = json_collection($query->get(), new ScoreTransformer(), 'user'); if ($user !== null) { $score = (clone $query)->where('user_id', $user->user_id)->first(); if ($score !== null) { $userScore = json_item($score, new ScoreTransformer(), 'user'); $userScorePosition = 1 + (clone $query)->limit(null)->where('score', '>', $score->score)->count(); } } return ['scoresList' => $scoresList, 'userScore' => $userScore ?? null, 'userScorePosition' => $userScorePosition ?? null]; }
public function getPlaymodeAttribute($value) { return Beatmap::modeStr($this->osu_playmode); }
public function gamemodeString() { return Beatmap::modeStr($this->game->play_mode); }
public function getModeAttribute() { return Beatmap::modeStr($this->play_mode); }
public function playModeStr() { return Beatmap::modeStr($this->play_mode); }