1
0
Fork 0

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
1 changed files with 35 additions and 0 deletions

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(),
]
];
}
}