RelatedParagraphResource.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use Illuminate\Http\Request;
  4. /**
  5. * 一本关联书:`GET /v3/tipitaka-related-paragraphs` 的 `data[]` 元素。
  6. *
  7. * 载荷是 Service 已拼好、补全书名/标签/目录路径的普通数组(不是 Eloquent 模型),
  8. * 本类只做纯映射。字段相对 v2 有改名:`book_title_pali`→`title`、`cs6_para`→`cs_para`。
  9. */
  10. class RelatedParagraphResource extends BaseResource
  11. {
  12. /**
  13. * @param Request $request
  14. * @return array{
  15. * book: int,
  16. * book_id: int,
  17. * title: string|null,
  18. * cs_para: int,
  19. * para: list<int>,
  20. * tags: list<string>,
  21. * path: list<array{title: string, level: int}>|null
  22. * }
  23. */
  24. public function toArray($request): array
  25. {
  26. return [
  27. 'book' => $this->resource['book'],
  28. 'book_id' => $this->resource['book_id'],
  29. 'title' => $this->resource['title'],
  30. 'cs_para' => $this->resource['cs_para'],
  31. 'para' => $this->resource['para'],
  32. 'tags' => $this->resource['tags'],
  33. 'path' => $this->resource['path'],
  34. ];
  35. }
  36. }