From fcabd961ce108817c4ea6f2f8a8abbd8be76b4db Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 12 Jan 2019 13:35:39 -0700 Subject: [PATCH] Add API StoryTransformer --- app/Transformer/Api/StoryTransformer.php | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/Transformer/Api/StoryTransformer.php diff --git a/app/Transformer/Api/StoryTransformer.php b/app/Transformer/Api/StoryTransformer.php new file mode 100644 index 000000000..3d87a5727 --- /dev/null +++ b/app/Transformer/Api/StoryTransformer.php @@ -0,0 +1,34 @@ + $story->id, + 'photo' => $story->profile->avatarUrl(), + 'name' => '', + 'link' => '', + 'lastUpdated' => $story->updated_at->format('U'), + 'seen' => $story->seen(), + 'items' => [], + ]; + } + + public function includeItems(Story $story) + { + $items = $story->items; + + return $this->collection($items, new StoryItemTransformer()); + } + +}