the browser-facing portion of osu!
at master 45 lines 1.2 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\UserAccountHistory; 9 10class UserAccountHistoryTransformer extends TransformerAbstract 11{ 12 protected array $availableIncludes = [ 13 'actor', 14 'supporting_url', 15 ]; 16 17 protected $permissions = [ 18 'actor' => 'UserSilenceShowExtendedInfo', 19 'supporting_url' => 'UserSilenceShowExtendedInfo', 20 ]; 21 22 public function transform(UserAccountHistory $h) 23 { 24 return [ 25 'description' => $h->reason, 26 'id' => $h->getKey(), 27 'length' => $h->period, 28 'permanent' => $h->permanent, 29 'timestamp' => json_time($h->timestamp), 30 'type' => $h->type, 31 ]; 32 } 33 34 public function includeActor(UserAccountHistory $h) 35 { 36 if ($h->actor !== null) { 37 return $this->item($h->actor, new UserCompactTransformer()); 38 } 39 } 40 41 public function includeSupportingUrl(UserAccountHistory $h) 42 { 43 return $this->primitive($h->supporting_url); 44 } 45}