DiscussionResource.php 957 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Http\Api\UserApi;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class DiscussionResource 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. return [
  16. "id"=>$this->id,
  17. "title"=> $this->title,
  18. "content"=> $this->content,
  19. "content_type"=> $this->content_type,
  20. "parent"=> $this->parent,
  21. "status"=> $this->status,
  22. "children_count"=> $this->children_count,
  23. "editor"=> UserApi::getByUuid($this->editor_uid),
  24. "res_id"=>$this->res_id,
  25. "res_type"=> $this->res_type,
  26. "created_at"=> $this->created_at,
  27. "updated_at"=> $this->updated_at,
  28. ];
  29. }
  30. }