فهرست منبع

match 匹配路由名称

jqh 5 سال پیش
والد
کامیت
bfb8c8918a
1فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 12 3
      src/Support/Helper.php

+ 12 - 3
src/Support/Helper.php

@@ -139,6 +139,10 @@ class Helper
         $html = '';
 
         foreach ((array) $attributes as $key => &$value) {
+            if (is_array($value)) {
+                $value = implode(' ', $value);
+            }
+
             if (is_numeric($key)) {
                 $key = $value;
             }
@@ -223,9 +227,9 @@ class Helper
      * 匹配请求路径.
      *
      * @example
-     *      Helper::matchRequestPath('auth/user')
-     *      Helper::matchRequestPath('auth/user*')
-     *      Helper::matchRequestPath('auth/user/* /edit')
+     *      Helper::matchRequestPath(admin_base_path('auth/user'))
+     *      Helper::matchRequestPath(admin_base_path('auth/user*'))
+     *      Helper::matchRequestPath(admin_base_path('auth/user/* /edit'))
      *      Helper::matchRequestPath('GET,POST:auth/user')
      *
      * @param string      $path
@@ -248,6 +252,11 @@ class Helper
             }
         }
 
+        // 判断路由名称
+        if ($request->routeIs($path)) {
+            return true;
+        }
+
         if (! Str::contains($path, '*')) {
             return $path === $current;
         }