AdminReport.php 1020 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. use App\Services\StatusService;
  7. class AdminReport extends JsonResource
  8. {
  9. /**
  10. * Transform the resource into an array.
  11. *
  12. * @return array<string, mixed>
  13. */
  14. public function toArray(Request $request): array
  15. {
  16. $res = [
  17. 'id' => $this->id,
  18. 'reporter' => AccountService::get($this->profile_id, true),
  19. 'type' => $this->type,
  20. 'object_id' => (string) $this->object_id,
  21. 'object_type' => $this->object_type,
  22. 'reported' => AccountService::get($this->reported_profile_id, true),
  23. 'status' => null,
  24. 'reporter_message' => $this->message,
  25. 'admin_seen_at' => $this->admin_seen,
  26. 'created_at' => $this->created_at,
  27. ];
  28. if($this->object_id && $this->object_type === 'App\Status') {
  29. $res['status'] = StatusService::get($this->object_id, false);
  30. }
  31. return $res;
  32. }
  33. }