IndexMeReactionRequest.php 995 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use App\Models\Reaction;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rule;
  6. /**
  7. * `GET /v3/me/reactions` 的入参:当前用户自己的 reaction 列表。
  8. *
  9. * 这里没有 user_id——结果集永远由登录态决定,不接受客户端指定。
  10. */
  11. class IndexMeReactionRequest extends FormRequest
  12. {
  13. /**
  14. * 登录检查在控制器里做:authorize() 返回 false 会渲染成 403,
  15. * 而「没登录」应该是 401。
  16. */
  17. public function authorize(): bool
  18. {
  19. return true;
  20. }
  21. /**
  22. * @return array<string, array<int, mixed>>
  23. */
  24. public function rules(): array
  25. {
  26. return [
  27. 'type' => ['nullable', 'string', Rule::in(Reaction::TYPES)],
  28. 'target_type' => ['nullable', 'string', Rule::in(Reaction::TARGET_TYPES)],
  29. 'page' => ['integer', 'min:1'],
  30. 'per_page' => ['integer', 'min:1', 'max:200'],
  31. ];
  32. }
  33. }