. Licensed under the GNU Affero General Public License v3.0. // See the LICENCE file in the repository root for full licence text. namespace App\Transformers; use App\Libraries\Commentable; use App\Models\Beatmapset; class CommentableMetaTransformer extends TransformerAbstract { public function transform(?Commentable $commentable) { if (isset($commentable)) { if ($commentable instanceof Beatmapset) { $ownerId = $commentable->user_id; $ownerTitle = 'MAPPER'; } return [ 'current_user_attributes' => [ 'can_new_comment_reason' => priv_check('CommentStore', $commentable)->message(), ], 'id' => $commentable->getKey(), 'type' => $commentable->getMorphClass(), 'title' => $commentable->commentableTitle(), 'url' => $commentable->url(), 'owner_id' => $ownerId ?? null, 'owner_title' => $ownerTitle ?? null, ]; } else { return [ 'title' => osu_trans('comments.commentable_name._deleted'), ]; } } }