Пример #1
0
 public function boot()
 {
     view()->composer('*', function ($view) {
         $menuId = request()->get('menuid');
         $routeName = app('router')->currentRouteName();
         if (empty($menuId)) {
             $menuId = app('menu')->select('id')->where('route', '=', $routeName)->first()['id'];
         }
         $params = ['submenus' => [], 'route_name' => $routeName, 'menuid' => $menuId];
         if (!empty($menuId)) {
             $menus = Menu::all();
             $submenus = [];
             foreach ($menus as $menu) {
                 if ($menu['parentid'] == $menuId) {
                     $submenus[] = $menu;
                 }
                 if ($menu['id'] == $menuId) {
                     $p = $menu;
                 }
             }
             array_unshift($submenus, $p);
             $params['submenus'] = $submenus;
         }
         $view->with($params);
     });
 }
Пример #2
0
 public function getEdit($id)
 {
     $weight_list = [];
     $menuitems_count = Menu::all()->count();
     for ($i = 1; $i <= $menuitems_count; $i++) {
         $weight_list[$i] = $i;
     }
     return view('admin.menu.edit', ['weight_list' => $weight_list, 'menuitem' => Menu::find($id), 'url' => config('medias.url')]);
 }
 public function getAll()
 {
     $top = DB::table('toplinks')->get();
     $links = $this->fetchTable(Menu::all());
     $sublinks = $this->getSublinks();
     $title = $this->getTitle('Home');
     $Links = array('titletest' => $title, 'menu' => $links, 'sublinks' => $sublinks, 'toplinks' => $top);
     return $Links;
 }
Пример #4
0
 public function edit($menuId)
 {
     $menus = Menu::all()->keyBy('id')->toArray();
     $parentId = $menus[$menuId]['parentid'];
     $menus = array_map(function ($menu) use($parentId) {
         $menu['selected'] = $menu['id'] == $parentId ? 'selected' : '';
         return $menu;
     }, $menus);
     $opt = "<option value='\$id' \$selected>\$spacer \$name</option>";
     $select = with(new Tree($menus))->getTree(0, $opt);
     return view('menus.edit', ['menu' => $menus[$menuId], 'select' => $select]);
 }
Пример #5
0
 public function leftMain(Request $request)
 {
     $menuId = $request->get('menuid');
     $menus = Menu::all()->toArray();
     $leftMenus = [];
     foreach ($menus as $menu) {
         if ($menu['parentid'] == $menuId) {
             $leftMenus[$menu['id']] = $menu;
         }
         if (isset($leftMenus[$menu['parentid']])) {
             $leftMenus[$menu['parentid']]['child'][] = $menu;
         }
     }
     return view('dash.left_main', ['left_menus' => $leftMenus]);
 }
Пример #6
0
 public static function get($title, $type)
 {
     $result = DB::table('global_blocks')->where('title', $title)->where('type', $type)->count();
     if ($result == 0) {
         DB::table('global_blocks')->insert(['title' => $title, 'type' => $type]);
     }
     $block = DB::table('global_blocks')->where('title', $title)->where('type', $type)->first();
     $menus = Menu::all();
     foreach ($menus as $row) {
         $pos = strpos($block->content, $row->tag);
         if ($pos !== false) {
             $navbar = new Nav($row->content, $row->type);
             $block->content = str_replace($row->tag, $navbar->get(), $block->content);
         }
     }
     return $block->content;
 }
Пример #7
0
 public function detail($id)
 {
     $page = 'catalog';
     $title = Menu::where('key', $page)->value('name');
     $menuHtml = $this->menuHtml($page);
     $menuItems = Menu::all();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     $pageInfo = Page::where('key', $page)->first();
     $categories = Category::orderBy('sort', 'asc')->get();
     $product = Product::with(['category', 'color'])->find($id);
     $product->increment('views');
     $recommended = Product::with('category')->take(4)->get();
     $smallCart = $this->smallCart();
     $cartItem = $this->cartItem($product->id);
     $page = $product;
     $page->title = $product->name;
     return view('site.product', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'title' => $title, 'page' => $page, 'product' => $product, 'categories' => $categories, 'recommended' => $recommended, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'currentItem' => $cartItem, 'currentProductCategory' => $product->category]);
 }
Пример #8
0
 public function index($page = '')
 {
     //        $title = Menu::where('key', $page)->value('name');
     $categories = Category::orderBy('sort', 'asc')->get();
     $menuHtml = $this->menuHtml($page);
     if (session()->has('cart')) {
         $cartItems = session()->get('cart');
         $sum = $cartItems->sum();
         $count = count($cartItems->all());
     } else {
         $sum = 0;
         $count = 0;
     }
     $menuItems = Menu::all();
     $products = Product::with('category')->orderBy('views', 'desc')->take(8)->get();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     $page = Page::where('key', 'index')->first();
     return view('index', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'categories' => $categories, 'count' => $count, 'sum' => $sum, 'products' => $products, 'indexFlag' => true, 'page' => $page]);
 }
Пример #9
0
 public function search(Request $request)
 {
     $page = new \stdClass();
     $page->title = 'Поиск';
     $page->keywords = 'Поиск';
     $page->description = 'Поиск';
     $page->key = 'search';
     $menuHtml = $this->menuHtml('cart');
     $menuItems = Menu::all();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     $categories = Category::orderBy('sort', 'asc')->get();
     $smallCart = $this->smallCart();
     if ($request->has('val')) {
         $products = Product::where('name', 'like', "%{$request->val}%")->orWhere('text', 'like', "%{$request->val}%")->get();
         $val = $request->get('val');
     } else {
         $val = '';
         $products = [];
     }
     return view('site.search', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'page' => $page, 'categories' => $categories, 'products' => $products, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'indexFlag' => true, 'search' => $val]);
 }
Пример #10
0
 public function index(Request $request)
 {
     $page = new \stdClass();
     $page->title = 'Корзина';
     $page->keywords = 'Корзина';
     $page->description = 'Корзина';
     $page->key = 'cart';
     //        $title = Menu::where('key', 'cart')->value('name');
     $menuHtml = $this->menuHtml('cart');
     $menuItems = Menu::all();
     $bottomMenuHtml = view('bottom', ['menuItems' => $menuItems])->render();
     //        $page = Page::where('key', $page)->first();
     $cart = $request->session()->get('cart');
     if ($cart) {
         $items = $cart->all();
     } else {
         $items = false;
     }
     $categories = Category::orderBy('sort', 'asc')->get();
     $smallCart = $this->smallCart();
     return view('site.cart', ['menuHtml' => $menuHtml, 'menuBottomHtml' => $bottomMenuHtml, 'page' => $page, 'items' => $items, 'categories' => $categories, 'count' => $smallCart['count'], 'sum' => $smallCart['sum'], 'deliverySum' => $smallCart['deliverySum'], 'totalSum' => $smallCart['deliverySum'] + $smallCart['sum']]);
 }
Пример #11
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $menus = Menu::all();
     return view($this->getManageView('index'))->withMenus($menus);
 }
Пример #12
0
 public function paypal_cancel()
 {
     return View('Runningshoes/pages/paypalCancel')->with(array('title' => $this->getTitle('Home'), 'links' => $this->fetchTable(Menu::all()), 'topLinks' => $this->fetchTable(DB::table('toplinks')->get())));
 }
Пример #13
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $menu = \App\Models\Menu::all();
     return view('menu', ['menu' => $menu, "title" => "Our Menu"]);
 }
Пример #14
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $menuItems = Menu::all();
     $data = ['route' => 'menu', 'title' => Menu::$tableName, 'menuItems' => $menuItems, 'menuNames' => Menu::$fields];
     return view('admin.menu.menuList', $data);
 }