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

View file

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