the browser-facing portion of osu!
at master 38 lines 1.2 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\TopicCover; 9use App\Transformers\TransformerAbstract; 10 11class TopicCoverTransformer extends TransformerAbstract 12{ 13 public function transform(TopicCover $cover) 14 { 15 if ($cover->filename === null) { 16 $data = [ 17 'method' => 'post', 18 'url' => route('forum.topic-covers.store', [ 19 'forum_id' => $cover->getForumId(), 20 'topic_id' => $cover->topic_id, 21 ]), 22 ]; 23 } else { 24 $data = [ 25 'method' => 'put', 26 'url' => route('forum.topic-covers.update', [$cover, 'topic_id' => $cover->topic_id]), 27 28 'id' => $cover->getKey(), 29 'fileUrl' => $cover->file()->url(), 30 ]; 31 } 32 33 $data['dimensions'] = $cover::MAX_DIMENSIONS; 34 $data['defaultFileUrl'] = $cover->defaultFileUrl(); 35 36 return $data; 37 } 38}