DiscussionResource.php 971 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Resources;
  3. use App\Http\Api\StudioApi;
  4. use App\Http\Api\AuthApi;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. class DiscussionResource extends JsonResource
  7. {
  8. /**
  9. * Transform the resource into an array.
  10. *
  11. * @param \Illuminate\Http\Request $request
  12. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  13. */
  14. public function toArray($request)
  15. {
  16. //获取用户信息
  17. $user = AuthApi::current($request);
  18. return [
  19. "id"=>$this->id,
  20. "title"=> $this->title,
  21. "content"=> $this->content,
  22. "parent"=> $this->parent,
  23. "children_count"=> $this->children_count,
  24. "editor"=> StudioApi::getById($this->editor_uid),
  25. "res_id"=>$this->res_id,
  26. "res_type"=> $this->res_type,
  27. "created_at"=> $this->created_at,
  28. "updated_at"=> $this->updated_at,
  29. ];
  30. }
  31. }