From dac326e94937807114c197f9a0b32eb5cb70d5b8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 18 May 2021 19:39:33 -0600 Subject: [PATCH] Update StatusTransformer, fix missing tags attribute --- app/Transformer/Api/StatusStatelessTransformer.php | 8 ++++++++ app/Transformer/Api/StatusTransformer.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/app/Transformer/Api/StatusStatelessTransformer.php b/app/Transformer/Api/StatusStatelessTransformer.php index 2190303e..b3ba463d 100644 --- a/app/Transformer/Api/StatusStatelessTransformer.php +++ b/app/Transformer/Api/StatusStatelessTransformer.php @@ -15,6 +15,7 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract { protected $defaultIncludes = [ 'account', + 'tags', 'media_attachments', ]; @@ -72,6 +73,13 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract return $this->item($account, new AccountTransformer()); } + public function includeTags(Status $status) + { + $tags = $status->hashtags; + + return $this->collection($tags, new HashtagTransformer()); + } + public function includeMediaAttachments(Status $status) { return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(3), function() use($status) { diff --git a/app/Transformer/Api/StatusTransformer.php b/app/Transformer/Api/StatusTransformer.php index a4359ae7..4ff62187 100644 --- a/app/Transformer/Api/StatusTransformer.php +++ b/app/Transformer/Api/StatusTransformer.php @@ -17,6 +17,7 @@ class StatusTransformer extends Fractal\TransformerAbstract { protected $defaultIncludes = [ 'account', + 'tags', 'media_attachments', ]; @@ -74,6 +75,13 @@ class StatusTransformer extends Fractal\TransformerAbstract return $this->item($account, new AccountTransformer()); } + public function includeTags(Status $status) + { + $tags = $status->hashtags; + + return $this->collection($tags, new HashtagTransformer()); + } + public function includeMediaAttachments(Status $status) { return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(14), function() use($status) {