the browser-facing portion of osu!
at master 1.4 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Http\Controllers; 7 8use App\Models\Multiplayer\Room; 9use App\Models\Season; 10use App\Transformers\SeasonTransformer; 11use App\Transformers\SelectOptionTransformer; 12 13class SeasonsController extends Controller 14{ 15 public function rooms($id) 16 { 17 $params = $this->paramsForResponse($id, request()->all()); 18 $roomsJson = Room::responseJson($params); 19 20 return $roomsJson; 21 } 22 23 public function show($id) 24 { 25 $season = Season::latestOrId($id); 26 27 $params = $this->paramsForResponse($season->getKey()); 28 $roomsJson = Room::responseJson($params); 29 30 $seasonJson = json_item($season, new SeasonTransformer()); 31 32 $seasons = Season::orderByDesc('id')->get(); 33 $seasonsJson = json_collection($seasons, new SelectOptionTransformer()); 34 35 return ext_view('seasons.show', compact('roomsJson', 'season', 'seasonJson', 'seasonsJson')); 36 } 37 38 private function paramsForResponse(int $seasonId, ?array $rawParams = null) 39 { 40 return [ 41 'cursor' => cursor_from_params($rawParams), 42 'limit' => get_int($rawParams['limit'] ?? null), 43 'mode' => 'all', 44 'season_id' => $seasonId, 45 ]; 46 } 47}