| 
									
										
										
										
											2019-01-12 20:35:39 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace App\Transformer\Api; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use App\Story; | 
					
						
							|  |  |  | use League\Fractal; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class StoryTransformer extends Fractal\TransformerAbstract | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     protected $defaultIncludes = [ | 
					
						
							|  |  |  |         'items', | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function transform(Story $story) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return [ | 
					
						
							| 
									
										
										
										
											2019-01-28 02:40:36 +00:00
										 |  |  |             'id'                        => (string) $story->id, | 
					
						
							| 
									
										
										
										
											2019-01-12 20:35:39 +00:00
										 |  |  |             '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()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |