StoreAdminCreditAdjustmentRequest.php 767 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. /**
  5. * `POST /v3/admin/credit-adjustments` 的入参:管理员给登录用户加减积分。
  6. */
  7. class StoreAdminCreditAdjustmentRequest extends FormRequest
  8. {
  9. public const MAX_DELTA = 1_000_000;
  10. public function authorize(): bool
  11. {
  12. return true;
  13. }
  14. /**
  15. * @return array<string, array<int, mixed>>
  16. */
  17. public function rules(): array
  18. {
  19. return [
  20. 'user' => ['required', 'string', 'max:255'],
  21. 'delta' => ['required', 'integer', 'not_in:0', 'between:-'.self::MAX_DELTA.','.self::MAX_DELTA],
  22. 'note' => ['required', 'string', 'max:255'],
  23. 'ref' => ['sometimes', 'uuid'],
  24. ];
  25. }
  26. }