the browser-facing portion of osu!
at master 35 lines 1.0 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\Transformers; 7 8use App\Models\Spotlight; 9use League\Fractal; 10 11class SpotlightTransformer extends TransformerAbstract 12{ 13 protected array $availableIncludes = [ 14 'participant_count', 15 ]; 16 17 public function transform(Spotlight $spotlight) 18 { 19 return [ 20 'end_date' => json_time($spotlight->end_date), 21 'id' => $spotlight->getKey(), 22 'mode_specific' => $spotlight->mode_specific, 23 'name' => $spotlight->name, 24 'start_date' => json_time($spotlight->start_date), 25 'type' => $spotlight->type, 26 ]; 27 } 28 29 public function includeParticipantCount(Spotlight $spotlight, Fractal\ParamBag $params) 30 { 31 $mode = $params->get('mode')[0]; 32 33 return $this->primitive($spotlight->participantCount($mode)); 34 } 35}