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\Http\Controllers;
7
8use App\Transformers\UserCompactTransformer;
9
10class GroupsController extends Controller
11{
12 public function show($id)
13 {
14 $group = app('groups')->byIdOrFail($id);
15 abort_unless($group->hasListing(), 404);
16
17 $currentMode = default_mode();
18 $users = $group->users()
19 ->with(UserCompactTransformer::listIncludesPreload($currentMode))
20 ->default()
21 ->orderBy('username', 'asc')
22 ->get();
23
24 $groupJson = json_item($group, 'Group', ['description']);
25 $usersJson = json_collection(
26 $users,
27 (new UserCompactTransformer())->setMode($currentMode),
28 UserCompactTransformer::LIST_INCLUDES,
29 );
30
31 return ext_view('groups.show', compact('groupJson', 'usersJson'));
32 }
33}