Update StatusStatelessTransformer, add missing attributes

This commit is contained in:
Daniel Supernault 2020-12-05 00:14:29 -07:00
parent bd321a72f0
commit 4d22426da2
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -5,6 +5,8 @@ namespace App\Transformer\Api;
use App\Status;
use League\Fractal;
use Cache;
use App\Services\HashidService;
use App\Services\MediaTagService;
class StatusStatelessTransformer extends Fractal\TransformerAbstract
{
@ -17,8 +19,11 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
public function transform(Status $status)
{
$taggedPeople = MediaTagService::get($status->id);
return [
'id' => (string) $status->id,
'shortcode' => HashidService::encode($status->id),
'uri' => $status->url(),
'url' => $status->url(),
'in_reply_to_id' => $status->in_reply_to_id,
@ -42,13 +47,17 @@ class StatusStatelessTransformer extends Fractal\TransformerAbstract
'language' => null,
'pinned' => null,
'mentions' => [],
'tags' => [],
'pf_type' => $status->type ?? $status->setType(),
'reply_count' => (int) $status->reply_count,
'comments_disabled' => $status->comments_disabled ? true : false,
'thread' => false,
'replies' => [],
'parent' => $status->parent() ? $this->transform($status->parent()) : [],
'parent' => [],
'place' => $status->place,
'local' => (bool) $status->local,
'taggedPeople' => $taggedPeople
];
}