From 4b593d95cab63ea38628f111316bd8ddefb534a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=9F=B3=E6=B1=89?= Date: Mon, 19 Oct 2020 12:14:48 +0800 Subject: [PATCH 1/3] update app/Http/Middleware/ParamsValidation.php. --- app/Http/Middleware/ParamsValidation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Middleware/ParamsValidation.php b/app/Http/Middleware/ParamsValidation.php index 7927928..c429f97 100644 --- a/app/Http/Middleware/ParamsValidation.php +++ b/app/Http/Middleware/ParamsValidation.php @@ -39,7 +39,7 @@ class ParamsValidation $rRoute = $request->route(); if( isset($rRoute[2]) && count($rRoute[2])>0 ) { - $RouteList = Utils::getRouteList(); + $RouteList = Utils::getRouteList($request->method()); $parasKey = $rRoute[2]; $path = array_filter($RouteList, function($v) use ($parasKey, $path) { $vv = $v; -- Gitee From 87a2dac1614b11253edfda10e3ab5615a644b5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=9F=B3=E6=B1=89?= Date: Mon, 19 Oct 2020 12:15:40 +0800 Subject: [PATCH 2/3] update app/Utils/Utils.php. --- app/Utils/Utils.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Utils/Utils.php b/app/Utils/Utils.php index afc62ac..e0585f4 100644 --- a/app/Utils/Utils.php +++ b/app/Utils/Utils.php @@ -66,4 +66,21 @@ class Utils return $result; } + /** + * 获取所有路由列表 + * @param string $method + * @return array + */ + public static function getRouteList($method='') + { + $path = []; + $routes = Route::getRoutes(); + foreach ($routes as $k=>$value) + { + if( strlen($method)>0 && $value['method'] != $method ) continue; + $path[] = $value['uri']; + } + + return $path; + } } \ No newline at end of file -- Gitee From ca878bd62cc377f2fab3e0c740121125c634e9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=9F=B3=E6=B1=89?= Date: Mon, 19 Oct 2020 12:17:33 +0800 Subject: [PATCH 3/3] update app/Validator/BaseValidator.php. --- app/Validator/BaseValidator.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Validator/BaseValidator.php b/app/Validator/BaseValidator.php index 074581c..a02e409 100644 --- a/app/Validator/BaseValidator.php +++ b/app/Validator/BaseValidator.php @@ -112,6 +112,13 @@ abstract class BaseValidator * @return array */ public function getRules() : array { + $request = $this->request; + $method = strtolower($request->method()); // "POST" + + if (isset($this->rules[$method][$this->uri])) { + return $this->rules[$method][$this->uri]; + } + if (isset($this->rules[$this->uri])) { return $this->rules[$this->uri]; } -- Gitee