46 lines
952 B
PHP
46 lines
952 B
PHP
|
<?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());
|
||
|
}
|
||
|
}
|