2019-01-12 13:35:39 -07: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-27 19:40:36 -07:00
|
|
|
'id' => (string) $story->id,
|
2019-01-12 13:35:39 -07:00
|
|
|
'photo' => $story->profile->avatarUrl(),
|
2020-02-18 00:40:37 -07:00
|
|
|
'name' => $story->profile->username,
|
|
|
|
'link' => $story->profile->url(),
|
2019-01-12 13:35:39 -07:00
|
|
|
'lastUpdated' => $story->updated_at->format('U'),
|
|
|
|
'seen' => $story->seen(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function includeItems(Story $story)
|
|
|
|
{
|
2020-02-18 00:40:37 -07:00
|
|
|
return $this->item($story, new StoryItemTransformer());
|
2019-01-12 13:35:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|