UpdateGroupRequest.php 922 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use App\Models\GroupInfo;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. /**
  6. * `PATCH /v3/groups/{group}` 的入参:改团队信息。只做局部更新,没有必填项。
  7. */
  8. class UpdateGroupRequest extends FormRequest
  9. {
  10. /**
  11. * 登录与权限在中间件 / Service 里判:authorize() 返回 false 会渲染成 403,
  12. * 而「没登录」应该是 401、「不是成员」要带具体文案。
  13. */
  14. public function authorize(): bool
  15. {
  16. return true;
  17. }
  18. /**
  19. * @return array<string, array<int, mixed>>
  20. */
  21. public function rules(): array
  22. {
  23. return [
  24. 'name' => ['sometimes', 'string', 'max:64'],
  25. 'description' => ['sometimes', 'nullable', 'string', 'max:1024'],
  26. 'status' => ['sometimes', 'integer', 'in:'.GroupInfo::STATUS_PRIVATE.','.GroupInfo::STATUS_PUBLIC],
  27. ];
  28. }
  29. }