IndexMeGroupRequest.php 894 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. /**
  5. * `GET /v3/me/groups` 的入参:我加入的团队。结果集由登录态决定,不接受指定用户。
  6. */
  7. class IndexMeGroupRequest extends FormRequest
  8. {
  9. /**
  10. * 登录与权限在中间件 / Service 里判:authorize() 返回 false 会渲染成 403,
  11. * 而「没登录」应该是 401、「不是成员」要带具体文案。
  12. */
  13. public function authorize(): bool
  14. {
  15. return true;
  16. }
  17. /**
  18. * @return array<string, array<int, mixed>>
  19. */
  20. public function rules(): array
  21. {
  22. return [
  23. 'owned' => ['sometimes', 'in:true,false,1,0'],
  24. 'search' => ['sometimes', 'nullable', 'string', 'max:64'],
  25. 'page' => ['integer', 'min:1'],
  26. 'per_page' => ['integer', 'min:1', 'max:200'],
  27. ];
  28. }
  29. }