DiscussionResource.php 871 B

12345678910111213141516171819202122232425262728293031
  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. "parent"=> $this->parent,
  20. "children_count"=> $this->children_count,
  21. "editor"=> StudioApi::getById($this->editor_uid),
  22. "res_id"=>$this->res_id,
  23. "res_type"=> $this->res_type,
  24. "created_at"=> $this->created_at,
  25. "updated_at"=> $this->updated_at,
  26. ];
  27. }
  28. }