This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/Controllers/OsuController.php

46 lines
952 B
PHP
Raw Normal View History

2016-12-11 18:51:45 +00:00
<?php
/**
* Holds the osu! specific stuff controller.
* @package Sakura
*/
namespace Sakura\Controllers;
use Sakura\CurrentSession;
use Sakura\DB;
use Sakura\Notification;
/**
* Notification stuff.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class OsuController extends Controller
{
private const MODES = [
'osu!standard',
'osu!taiko',
'osu!catch',
'osu!mania',
];
public function leaderboard(): string
{
return view('osu/leaderboard', ['gamemodes' => static::MODES]);
}
public function leaderboardData(): string
{
$mode = $_GET['mode'] ?? -1;
if (!array_key_exists($mode, static::MODES)) {
return $this->json(['error' => 'Invalid game mode.']);
}
return $this->json(DB::table('osu_leaderboard')
->where('osu_game_mode', $mode)
->orderBy('osu_rank')
->get());
}
}