IndexReactionTallyRequest.php 768 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use App\Models\Reaction;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. /**
  6. * `GET /v3/reactions/tally` 的入参:某个 target 的各 type 计数摘要。
  7. *
  8. * 聚合结果每个 type 一行,总行数不超过 {@see Reaction::TYPES} 的长度,
  9. * 所以不分页,也就没有 page / per_page。
  10. */
  11. class IndexReactionTallyRequest extends FormRequest
  12. {
  13. /**
  14. * 公共只读端点,不需要鉴权;登录时才额外富化 selected / id。
  15. */
  16. public function authorize(): bool
  17. {
  18. return true;
  19. }
  20. /**
  21. * @return array<string, array<int, mixed>>
  22. */
  23. public function rules(): array
  24. {
  25. return [
  26. 'target_id' => ['required', 'uuid'],
  27. ];
  28. }
  29. }