AccountTransformer.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Transformer\Api;
  3. use App\Profile;
  4. use League\Fractal;
  5. class AccountTransformer extends Fractal\TransformerAbstract
  6. {
  7. public function transform(Profile $profile)
  8. {
  9. $is_admin = $profile->domain ? false : $profile->user->is_admin;
  10. return [
  11. 'id' => (string) $profile->id,
  12. 'username' => $profile->username,
  13. 'acct' => $profile->username,
  14. 'display_name' => $profile->name,
  15. 'locked' => (bool) $profile->is_private,
  16. 'created_at' => null,
  17. 'followers_count' => $profile->followerCount(),
  18. 'following_count' => $profile->followingCount(),
  19. 'statuses_count' => (int) $profile->statusCount(),
  20. 'note' => $profile->bio,
  21. 'url' => $profile->url(),
  22. 'avatar' => $profile->avatarUrl(),
  23. 'avatar_static' => $profile->avatarUrl(),
  24. 'header' => null,
  25. 'header_static' => null,
  26. 'header_bg' => $profile->header_bg,
  27. 'moved' => null,
  28. 'fields' => null,
  29. 'bot' => null,
  30. 'website' => $profile->website,
  31. 'software' => 'pixelfed',
  32. 'is_admin' => (bool) $is_admin
  33. ];
  34. }
  35. }