the browser-facing portion of osu!
at master 36 lines 951 B 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\UpdateStream; 9 10class UpdateStreamTransformer extends TransformerAbstract 11{ 12 protected array $availableIncludes = [ 13 'latest_build', 14 'user_count', 15 ]; 16 17 public function transform(UpdateStream $stream) 18 { 19 return [ 20 'id' => $stream->getKey(), 21 'name' => $stream->name, 22 'display_name' => $stream->pretty_name, 23 'is_featured' => $stream->isFeatured(), 24 ]; 25 } 26 27 public function includeLatestBuild(UpdateStream $stream) 28 { 29 return $this->item($stream->latestBuild(), new BuildTransformer()); 30 } 31 32 public function includeUserCount(UpdateStream $stream) 33 { 34 return $this->primitive($stream->userCount()); 35 } 36}