浏览代码

refactor(MacroPageMiddleware): 更新输入获取方式以提高一致性

- 将 input() 方法替换为 $this->get() 方法获取 page 参数
- 将 input() 方法替换为 $this->get() 方法获取 limit 和 per_page 参数
- 保持原有的参数验证逻辑不变
- 确保默认值和边界检查仍然有效
runphp 3 月之前
父节点
当前提交
dc9b329cdc
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/Middleware/MacroPageMiddleware.php

+ 2 - 2
src/Middleware/MacroPageMiddleware.php

@@ -13,8 +13,8 @@ class MacroPageMiddleware
     public function handle(Request $request, Closure $next): Response
     {
         $request->macro('pageAndLimit', function (): array {
-            $page = input('page/d', 1);
-            $limit = input('limit/d', input('per_page/d', 10));
+            $page = $this->get('page/d', 1);
+            $limit = $this->get('limit/d', $this->get('per_page/d', 10));
             throw_if($page < 1, Exception::class, '页码不能小于1');
             throw_if($limit < 1 || $limit > 200, Exception::class, '每页数量必须在1-200之间');
             return ['page' => $page, 'list_rows' => $limit];