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\Follow;
9
10class FollowModdingTransformer extends FollowTransformer
11{
12 protected array $availableIncludes = [
13 'latest_beatmapset',
14 'user',
15 ];
16
17 private $latestBeatmapsets;
18
19 public function __construct($latestBeatmapsets = null)
20 {
21 // should be keyed by "id"
22 $this->latestBeatmapsets = $latestBeatmapsets;
23 }
24
25 public function includeUser(Follow $follow)
26 {
27 return $this->item($follow->notifiable, new UserCompactTransformer());
28 }
29
30 public function includeLatestBeatmapset(Follow $follow)
31 {
32 $comment = $this->latestBeatmapsets[$follow->notifiable_id] ?? null;
33
34 if ($comment !== null) {
35 return $this->item($comment, new BeatmapsetTransformer());
36 }
37 }
38}