diff --git a/app/Models/Admin/Layout/Menu.php b/app/Models/Admin/Layout/Menu.php new file mode 100644 index 00000000..de9d655c --- /dev/null +++ b/app/Models/Admin/Layout/Menu.php @@ -0,0 +1,54 @@ +path(); + } + if (empty($item['children'])) { + if (empty($item['uri'])) { + return false; + } + // return trim($this->getPath($item['uri']), '/') == $path; + // dd($path, trim($this->getPath($item['uri']), '/admin'), strpos($path, trim($this->getPath($item['uri']), '/admin'))); + $_uri = trim($this->getPath($item['uri']), '/admin'); + if (empty($_uri) && $path!=='admin') { + return false; + } + return strpos($path, $_uri) !== false; + } + + + foreach ($item['children'] as $v) { + // $_uri = trim($this->getPath($item['uri']), '/admin'); + // if (empty($_uri) && $path!=='admin') { + // return false; + // } + // if (strpos($path, $_uri) !== false) { + // return true; + // } + dd($v, empty($v['children'])); + if (! empty($v['children'])) { + dd($v, $path); + if ($this->isActive($v, $path)) { + return true; + } + } + } + + return false; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 28280dd0..6a84dfc0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Models\Admin\Layout\Menu; use App\Services\SettingService; use EasyWeChat\Factory as EasyWeChatFactory; use EasyWeChat\Payment\Application as EasyWeChatPaymentApplication; @@ -24,6 +25,7 @@ class AppServiceProvider extends ServiceProvider $this->registerEasyWeChat(); $this->registerRequestRealIp(); $this->registerSettings(); + // $this->registerAdminMenu(); } /** @@ -48,6 +50,11 @@ class AppServiceProvider extends ServiceProvider JsonResource::withoutWrapping(); } + protected function registerAdminMenu() + { + $this->app->singleton('admin.menu', Menu::class); + } + /** * 注册微信服务 *