Exemplo n.º 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();
     });
 }
Exemplo n.º 2
0
/**
 * Get the current shop id
 *
 * @return null|string
 */
function shopId()
{
    if (!($shop = shop())) {
        return null;
    }
    if (is_string($shop)) {
        return $shop;
    }
    if ($shop instanceof \App\Modules\ShopModule\Entities\Shop) {
        return $shop->id;
    }
    return null;
}
Exemplo n.º 3
0
 public function handle(Request $request, Closure $next)
 {
     if (!Auth::check()) {
         abort(500);
     }
     if ($shop = shop() and !$shop->getOwner()->is(Auth::user())) {
         throw new AuthorizationException('只有店主能访问', 403);
     }
     $reauth = $this->getShopReauthLimiter($request);
     if (!$reauth->check()) {
         $request->session()->set('url.intended', $request->url());
         return $this->invalidated($request);
     }
     $reauth->refresh();
     return $next($request);
 }
Exemplo n.º 4
0
 public function delete(User $user, AttributeGroup $attributeGroup)
 {
     return isRouteInShop() and shop()->is($attributeGroup->seller);
 }
Exemplo n.º 5
0
 public function index(AddressManager $addressManager)
 {
     $address = $addressManager->getAddressRepository()->whereOwner(shop())->first();
     $cities = $addressManager->getCities();
     return view('shop::__shop.settings', compact('address', 'cities'));
 }