1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 16:24:29 +00:00
pixelfed/app/Transformer/Api/StoryItemTransformer.php

29 lines
902 B
PHP
Raw Normal View History

2019-01-12 20:36:07 +00:00
<?php
namespace App\Transformer\Api;
use App\StoryItem;
use League\Fractal;
use Illuminate\Support\Str;
class StoryItemTransformer extends Fractal\TransformerAbstract
{
public function transform(StoryItem $item)
{
return [
2020-02-18 07:39:56 +00:00
'id' => (string) $item->id,
2019-01-12 20:36:07 +00:00
'type' => $item->type,
2020-02-18 07:39:56 +00:00
'length' => $item->duration != 0 ? $item->duration : 3,
2019-01-12 20:36:07 +00:00
'src' => $item->url(),
'preview' => null,
'link' => null,
'linkText' => null,
2020-02-18 07:39:56 +00:00
'time' => $item->created_at->format('U'),
'expires_at' => $item->created_at->addHours(24)->format('U'),
2019-01-12 20:36:07 +00:00
'seen' => $item->story->seen(),
];
}
}