1
0
Fork 0

Update StatusTransformer

This commit is contained in:
Daniel Supernault 2019-05-26 23:03:53 -06:00
parent 1f3a5e263b
commit 1c900a4ba4
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 6 additions and 3 deletions

View File

@ -46,7 +46,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
'reply_count' => (int) $status->reply_count,
'comments_disabled' => $status->comments_disabled ? true : false,
'thread' => false,
'replies' => []
'replies' => [],
'parent' => $status->parent() ? $this->transform($status->parent()) : [],
];
}
@ -67,8 +68,10 @@ class StatusTransformer extends Fractal\TransformerAbstract
public function includeMediaAttachments(Status $status)
{
return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(3), function() use($status) {
$media = $status->media()->orderBy('order')->get();
return $this->collection($media, new MediaTransformer());
if(in_array($status->type, ['photo', 'video'])) {
$media = $status->media()->orderBy('order')->get();
return $this->collection($media, new MediaTransformer());
}
});
}