상속: extends Spatie\Menu\Link, use trait Illuminate\Support\Traits\Macroable
예제 #1
1
 private function registerShopMenu()
 {
     Menu::macro('shop', function () {
         return Menu::new()->addClass('nav metismenu')->setAttribute('id', 'side-menu')->add(Html::raw('<div class="profile-element">' . '<span class="clear">' . '<span class="block m-t-xs">' . '<strong class="font-bold text-muted">' . shop()->name . '</strong>' . '</span>' . '<span class="text-muted text-xs block">卖家</span>' . '</span>' . '</div>' . '<div class="logo-element">格</div>')->addParentClass('nav-header'))->add(Link::shopRoute('shop::home', '<i class="fa fa-home fa-fw"></i> <span class="nav-label">后台首页</span>'))->submenu(Link::to('#', '<i class="fa fa-wrench fa-fw"></i> <span class="nav-label">店铺设置</span><span class="fa arrow"></span>')->addClass('dropdown-toggle')->setAttributes(['data-toggle' => 'dropdown', 'role' => 'button']), Menu::new()->addClass('nav nav-second-level collapse')->add(Link::shopRoute('shop::settings.index', '基本设置'))->add(Link::shopRoute('shop::payment.index', '付款方式'))->add(Link::shopRoute('shop::shipping.index', '邮费方案')))->add(Link::shopRoute('shop::products.index', '<i class="fa fa-cubes fa-fw"></i> <span class="nav-label">商品管理</span>'))->add(Link::shopRoute('shop::orders.index', '<i class="fa fa-files-o fa-fw"></i> <span class="nav-label">订单管理</span>'))->add(Link::route('front::home', '<i class="fa fa-shopping-bag fa-fw"></i> <span class="nav-label">商城首页</span>')->addParentClass('special_link'))->setActiveFromRequest();
     });
     Menu::macro('editProduct', function ($product) {
         $inShop = isRouteInShop();
         return Menu::new()->addClass('nav nav-tabs')->add(Link::sellerRoute('products.edit', '基本信息', [$product->id]))->add(Link::sellerRoute('products.categories.index', '商品分类', [$product->id]))->addIf($inShop, $inShop ? Link::sellerRoute('products.attributes.index', '商品属性', [$product->id]) : Html::raw(''))->addIf($inShop, $inShop ? Link::sellerRoute('products.variants.index', '库存管理', [$product->id]) : Html::raw(''))->add(Link::sellerRoute('products.shipping.index', '邮费设置', [$product->id]))->addIf($inShop, $inShop ? Link::sellerRoute('products.sales.index', '促销活动', [$product->id]) : Html::raw(''))->add(Link::sellerRoute('products.images.index', '商品图片', [$product->id]))->setActiveFromRequest();
     });
 }
예제 #2
0
 /**
  * @param string|array $authorization
  * @param string $name
  * @param string $text
  * @param array $parameters
  * @param bool $absolute
  * @param \Illuminate\Routing\Route|null $route
  *
  * @return $this
  */
 public function routeIfCan($authorization, string $name, string $text, array $parameters = [], bool $absolute = true, $route = null)
 {
     return $this->addIfCan($authorization, Link::toRoute($name, $text, $parameters, $absolute, $route));
 }