IndexTipitakaWordParagraphRequest.php 1003 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. /**
  4. * `GET /v3/tipitaka-word-paragraphs`:按词形找段落。检索条件同聚合端点,另加书的过滤与分页。
  5. */
  6. class IndexTipitakaWordParagraphRequest extends AggregateTipitakaWordParagraphRequest
  7. {
  8. /**
  9. * @return array<string, array<int, mixed>>
  10. */
  11. public function rules(): array
  12. {
  13. return parent::rules() + [
  14. 'book_id' => ['sometimes', 'string', 'regex:/^\d+(,\d+)*$/', 'max:2000'],
  15. 'page' => ['sometimes', 'integer', 'min:1'],
  16. 'per_page' => ['sometimes', 'integer', 'min:1', 'max:100'],
  17. ];
  18. }
  19. /**
  20. * @return array{words: list<string>, bold: string|null, book_ids: list<int>}
  21. */
  22. public function criteria(): array
  23. {
  24. $bookIds = $this->validated('book_id');
  25. return parent::criteria() + [
  26. 'book_ids' => $bookIds === null ? [] : array_values(array_unique(array_map('intval', explode(',', $bookIds)))),
  27. ];
  28. }
  29. }