the browser-facing portion of osu!
at master 42 lines 1.1 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\LegacyMatch; 7 8use App\Models\LegacyMatch\Event; 9use App\Transformers\TransformerAbstract; 10use App\Transformers\UserCompactTransformer; 11 12class EventTransformer extends TransformerAbstract 13{ 14 protected array $availableIncludes = [ 15 'user', 16 'game', 17 ]; 18 19 public function transform(Event $event) 20 { 21 return [ 22 'id' => $event->event_id, 23 'detail' => $event->detail, 24 'timestamp' => json_time($event->timestamp), 25 'user_id' => $event->user_id, 26 ]; 27 } 28 29 public function includeUser(Event $event) 30 { 31 if ($event->user) { 32 return $this->item($event->user, new UserCompactTransformer()); 33 } 34 } 35 36 public function includeGame(Event $event) 37 { 38 if ($event->game) { 39 return $this->item($event->game, new GameTransformer()); 40 } 41 } 42}