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\Group;
9
10class GroupTransformer extends TransformerAbstract
11{
12 protected array $availableIncludes = ['description'];
13
14 public function transform(Group $group)
15 {
16 return [
17 'colour' => $group->colour,
18 'has_listing' => $group->hasListing(),
19 'has_playmodes' => $group->has_playmodes,
20 'id' => $group->getKey(),
21 'identifier' => $group->identifier,
22 'is_probationary' => $group->isProbationary(),
23 'name' => $group->group_name,
24 'short_name' => $group->short_name,
25 ];
26 }
27
28 public function includeDescription(Group $group)
29 {
30 return $this->primitive($group->group_desc === null ? null : [
31 'html' => $group->descriptionHtml(),
32 'markdown' => $group->group_desc,
33 ]);
34 }
35}