ShowAdminStatsRequest.php 823 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. /**
  5. * 管理后台统计(`/v3/admin/reading-stats`、`/v3/admin/agent-stats`)的共同入参:
  6. * UTC 日的闭区间 [from, to],缺省近 30 天,最长 366 天。
  7. */
  8. class ShowAdminStatsRequest extends FormRequest
  9. {
  10. public const MAX_DAYS = 366;
  11. public function authorize(): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * @return array<string, array<int, mixed>>
  17. */
  18. public function rules(): array
  19. {
  20. return [
  21. 'from' => ['sometimes', 'date_format:Y-m-d'],
  22. 'to' => ['sometimes', 'date_format:Y-m-d', 'after_or_equal:from'],
  23. 'client' => ['sometimes', 'in:all,web,mobile'],
  24. 'account_type' => ['sometimes', 'in:all,user,guest'],
  25. ];
  26. }
  27. }