route()->getName(); if (Str::startsWith($routeName, ['admin.products.', 'admin.categories.'])) { $this->addLink('商品分类', admin_route('categories.index'), 'fa fa-tachometer-alt', false); $this->addLink('商品列表', admin_route('products.index'), 'fa fa-tachometer-alt', false); $this->addLink('回收站', admin_route('products.index', ['trashed' => 1]), 'fa fa-tachometer-alt', false); } return view('admin::components.sidebar'); } public function addLink($title, $url, $icon, $active) { $this->links[] = [ 'title' => $title, 'url' => $url, 'icon' => $icon, 'active' => $active ]; } }