1
0
Fork 0

Add API Search ResultsTransformer

This commit is contained in:
Daniel Supernault 2019-01-12 13:58:35 -07:00
parent ba8c101703
commit 84960d701c
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 23 additions and 5 deletions

View File

@ -8,12 +8,12 @@ class ResultsTransformer extends Fractal\TransformerAbstract
{
protected $defaultIncludes = [
'account',
'mentions',
'media_attachments',
'tags',
'accounts',
'statuses',
'hashtags',
];
public function transform()
public function transform($results)
{
return [
'accounts' => [],
@ -21,4 +21,22 @@ class ResultsTransformer extends Fractal\TransformerAbstract
'hashtags' => []
];
}
public function includeAccounts($results)
{
$accounts = $results->accounts;
return $this->collection($accounts, new AccountTransformer());
}
public function includeStatuses($results)
{
$statuses = $results->statuses;
return $this->collection($statuses, new StatusTransformer());
}
public function includeTags($results)
{
$hashtags = $status->hashtags;
return $this->collection($hashtags, new HashtagTransformer());
}
}