AdminSpamReport.php 673 B

123456789101112131415161718192021222324252627282930313233
  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 AdminSpamReport 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. 'type' => $this->type,
  19. 'status' => null,
  20. 'read_at' => $this->read_at,
  21. 'created_at' => $this->created_at,
  22. ];
  23. if($this->item_id && $this->item_type === 'App\Status') {
  24. $res['status'] = StatusService::get($this->item_id, false);
  25. }
  26. return $res;
  27. }
  28. }