2018-07-12 16:42:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Transformer\Api;
|
|
|
|
|
|
|
|
use App\Profile;
|
|
|
|
use League\Fractal;
|
|
|
|
|
|
|
|
class AccountTransformer extends Fractal\TransformerAbstract
|
|
|
|
{
|
2018-12-31 04:26:37 +00:00
|
|
|
public function transform(Profile $profile)
|
|
|
|
{
|
2019-01-28 02:40:36 +00:00
|
|
|
$is_admin = $profile->domain ? false : $profile->user->is_admin;
|
2018-12-31 04:26:37 +00:00
|
|
|
return [
|
2019-01-28 02:40:36 +00:00
|
|
|
'id' => (string) $profile->id,
|
2018-12-31 04:26:37 +00:00
|
|
|
'username' => $profile->username,
|
|
|
|
'acct' => $profile->username,
|
|
|
|
'display_name' => $profile->name,
|
|
|
|
'locked' => (bool) $profile->is_private,
|
|
|
|
'created_at' => $profile->created_at->format('c'),
|
|
|
|
'followers_count' => $profile->followerCount(),
|
|
|
|
'following_count' => $profile->followingCount(),
|
|
|
|
'statuses_count' => $profile->statusCount(),
|
|
|
|
'note' => $profile->bio,
|
|
|
|
'url' => $profile->url(),
|
|
|
|
'avatar' => $profile->avatarUrl(),
|
|
|
|
'avatar_static' => $profile->avatarUrl(),
|
|
|
|
'header' => null,
|
|
|
|
'header_static' => null,
|
|
|
|
'moved' => null,
|
|
|
|
'fields' => null,
|
|
|
|
'bot' => null,
|
2019-02-11 04:48:40 +00:00
|
|
|
'website' => $profile->website,
|
2019-01-28 02:40:36 +00:00
|
|
|
'software' => 'pixelfed',
|
|
|
|
'is_admin' => (bool) $is_admin
|
2018-12-31 04:26:37 +00:00
|
|
|
];
|
|
|
|
}
|
2018-08-28 03:07:36 +00:00
|
|
|
}
|