From 84960d701cf873bc7d33e6c937d32bf89b40bd90 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 12 Jan 2019 13:58:35 -0700 Subject: [PATCH] Add API Search ResultsTransformer --- app/Transformer/Api/ResultsTransformer.php | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/app/Transformer/Api/ResultsTransformer.php b/app/Transformer/Api/ResultsTransformer.php index ea247360..781e9ddf 100644 --- a/app/Transformer/Api/ResultsTransformer.php +++ b/app/Transformer/Api/ResultsTransformer.php @@ -8,12 +8,12 @@ class ResultsTransformer extends Fractal\TransformerAbstract { protected $defaultIncludes = [ - 'account', - 'mentions', - 'media_attachments', - 'tags', + 'accounts', + 'statuses', + 'hashtags', ]; - public function transform() + + public function transform($results) { return [ 'accounts' => [], @@ -21,4 +21,22 @@ class ResultsTransformer extends Fractal\TransformerAbstract 'hashtags' => [] ]; } + + public function includeAccounts($results) + { + $accounts = $results->accounts; + return $this->collection($accounts, new AccountTransformer()); + } + + public function includeStatuses($results) + { + $statuses = $results->statuses; + return $this->collection($statuses, new StatusTransformer()); + } + + public function includeTags($results) + { + $hashtags = $status->hashtags; + return $this->collection($hashtags, new HashtagTransformer()); + } }