Add StatusHashtagTransformer

This commit is contained in:
Daniel Supernault 2019-06-30 22:22:35 -06:00
parent 5ef7936b48
commit 9d7943a9de
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -0,0 +1,35 @@
<?php
namespace App\Transformer\Api;
use App\{Hashtag, Status, StatusHashtag};
use League\Fractal;
class StatusHashtagTransformer extends Fractal\TransformerAbstract
{
public function transform(StatusHashtag $statusHashtag)
{
$hashtag = $statusHashtag->hashtag;
$status = $statusHashtag->status;
$profile = $statusHashtag->profile;
return [
'status' => [
'type' => $status->type,
'url' => $status->url(),
'thumb' => $status->thumb(),
'sensitive' => (bool) $status->is_nsfw,
'like_count' => $status->likes_count,
'share_count' => $status->reblogs_count,
'user' => [
'username' => $profile->username,
'url' => $profile->url(),
]
],
'hashtag' => [
'name' => $hashtag->name,
'url' => $hashtag->url(),
]
];
}
}