AdminProfile.php 835 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. use App\Services\AccountService;
  6. class AdminProfile extends JsonResource
  7. {
  8. /**
  9. * Transform the resource into an array.
  10. *
  11. * @return array<string, mixed>
  12. */
  13. public function toArray(Request $request): array
  14. {
  15. $res = AccountService::get($this->id, true);
  16. $res['domain'] = $this->domain;
  17. $res['status'] = $this->status;
  18. $res['limits'] = [
  19. 'exist' => $this->cw || $this->unlisted || $this->no_autolink,
  20. 'autocw' => (bool) $this->cw,
  21. 'unlisted' => (bool) $this->unlisted,
  22. 'no_autolink' => (bool) $this->no_autolink,
  23. 'banned' => (bool) $this->status == 'banned'
  24. ];
  25. return $res;
  26. }
  27. }