public function isValidRank($user) { if (!$user) { return false; } $stats = $user->statistics(play_mode_string($this->play_mode), true)->firstOrNew([]); if ($this->rank_min !== null && $this->rank_min > $stats->rank_score_index) { return false; } if ($this->rank_max !== null && $this->rank_max < $stats->rank_score_index) { return false; } return true; }
public function getPlaymodeAttribute($value) { return play_mode_string($this->osu_playmode); }
public function getUser() { $id = Request::input('u'); $mode = Request::input('m', 0); $type = Request::input('type'); $event_days = min(31, (int) Request::input('event_days', 1)); if (!in_array($mode, [Beatmap::OSU, Beatmap::TAIKO, Beatmap::FRUITS, Beatmap::MANIA])) { return Response::json([]); } $user = User::lookup($id, $type); if (!$user) { return Response::json([]); } $stats = fractal_api_serialize_item($user->statistics(play_mode_string($mode), true)->first(), new StatisticsTransformer()); $events = fractal_api_serialize_collection($user->events()->where('date', '>', Carbon::now()->addDays(-$event_days))->orderBy('event_id', 'desc')->get(), new EventTransformer()); $user = fractal_api_serialize_item($user, new UserTransformer()); $combined = array_merge($user, $stats, ['events' => $events]); return Response::json([$combined]); }