the browser-facing portion of osu!
at master 38 lines 1.1 kB 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\Forum; 7 8use App\Models\Forum\Post; 9use App\Transformers\TransformerAbstract; 10 11class PostTransformer extends TransformerAbstract 12{ 13 protected array $availableIncludes = [ 14 'body', 15 ]; 16 17 public function transform(Post $post) 18 { 19 return [ 20 'created_at' => json_time($post->post_time), 21 'deleted_at' => json_time($post->deleted_at), 22 'edited_at' => json_time($post->post_edit_time), 23 'edited_by_id' => $post->post_edit_user, 24 'forum_id' => $post->forum_id, 25 'id' => $post->getKey(), 26 'topic_id' => $post->topic_id, 27 'user_id' => $post->poster_id, 28 ]; 29 } 30 31 public function includeBody(Post $post) 32 { 33 return $this->primitive([ 34 'html' => $post->bodyHTML(), 35 'raw' => $post->bodyRaw, 36 ]); 37 } 38}