NotificationResource.php 929 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. use App\Http\Api\UserApi;
  5. class NotificationResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  12. */
  13. public function toArray($request)
  14. {
  15. $data = [
  16. "id"=>$this->id,
  17. "from"=> UserApi::getByUuid($this->from),
  18. "to"=> UserApi::getByUuid($this->to),
  19. "url"=> $this->url,
  20. "content"=> $this->content,
  21. "content_type"=> $this->content_type,
  22. "res_type"=> $this->res_type,
  23. "res_id"=> $this->res_id,
  24. "status"=> $this->status,
  25. "created_at"=> $this->created_at,
  26. "updated_at"=> $this->updated_at,
  27. ];
  28. return $data;
  29. }
  30. }