DiscussionResource.php 921 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Http\Api\StudioApi;
  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. "children_count"=> $this->children_count,
  22. "editor"=> StudioApi::getById($this->editor_uid),
  23. "res_id"=>$this->res_id,
  24. "res_type"=> $this->res_type,
  25. "created_at"=> $this->created_at,
  26. "updated_at"=> $this->updated_at,
  27. ];
  28. }
  29. }