/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     ////////////////////////////////////
     // Create menu: root
     $menuRoot = Menu::create(['name' => 'root', 'label' => 'Root', 'icon' => null, 'separator' => false, 'url' => null, 'enabled' => true, 'position' => 0]);
     // Force root parent to itself.
     $menuRoot->parent_id = $menuRoot->id;
     $menuRoot->save();
     // Two examples provided to get you started!
     //        // Create Home menu
     //        $menuHome = Menu::create([
     //            'name'          => 'home',
     //            'label'         => 'Home',
     //            'icon'          => 'fa fa-home fa-colour-green',
     //            'separator'     => false,
     //            'url'           => '/',
     //            'enabled'       => true,
     //            'position'      => 0,
     //            'parent_id'     => $menuRoot->id,       // Parent is root.
     //        ]);
     //        // Create Dashboard menu
     //        $menuDashboard = Menu::create([
     //            'name'          => 'dashboard',
     //            'label'         => 'Dashboard',
     //            'icon'          => 'fa fa-dashboard',
     //            'separator'     => false,
     //            'url'           => '/dashboard',
     //            'enabled'       => true,
     //            'position'      => 0,
     //            'parent_id'     => $menuHome->id,       // Parent is home.
     //        ]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /////////
     // Find root menu.
     $menuRoot = Menu::where('name', 'root')->first();
     // Create Demo container.
     $menuPackageHome = Menu::create(['name' => 'package-home', 'label' => 'sroutier/menu-builder', 'icon' => 'fa fa-github', 'separator' => false, 'url' => "https://github.com/sroutier/menu-builder", 'enabled' => true, 'position' => 0, 'parent_id' => $menuRoot->id]);
     $menuHome = Menu::create(['name' => 'home', 'label' => 'Home', 'icon' => 'fa fa-home', 'separator' => false, 'url' => "/", 'enabled' => true, 'position' => 1, 'parent_id' => $menuRoot->id]);
     $menuDemo = Menu::create(['name' => 'demo', 'label' => 'Demo', 'icon' => 'fa fa-book fa-colour-blue', 'separator' => false, 'url' => "/menu-builder-demo/home", 'enabled' => true, 'position' => 2, 'parent_id' => $menuRoot->id]);
     // Create Sub menu 1 container.
     $menuDemoSub1 = Menu::create(['name' => 'sub-menu-1', 'label' => 'Sub menu 1', 'icon' => 'fa fa-bookmark', 'separator' => false, 'url' => "/menu-builder-demo/one", 'enabled' => true, 'position' => 0, 'parent_id' => $menuDemo->id]);
     // Create Sub menu 2 container.
     $menuDemoSub2 = Menu::create(['name' => 'sub-menu-2', 'label' => 'Sub menu 2', 'icon' => 'fa fa-bookmark-o', 'separator' => false, 'url' => "/menu-builder-demo/two", 'enabled' => true, 'position' => 1, 'parent_id' => $menuDemo->id]);
     // Create Admin container.
     $menuAdmin = Menu::create(['name' => 'admin', 'label' => 'Admin', 'icon' => 'fa fa-cog fa-colour-red', 'separator' => false, 'url' => null, 'enabled' => true, 'position' => 999, 'parent_id' => $menuRoot->id]);
     // Create Menus sub-menu
     $menuMenus = Menu::create(['name' => 'menus', 'label' => 'Menus', 'icon' => 'fa fa-bars', 'separator' => false, 'url' => "/admin/menus", 'enabled' => true, 'position' => 0, 'parent_id' => $menuAdmin->id]);
 }
Exemplo n.º 3
0
 /**
  * @param null $leaf
  * @return mixed|null
  * @throws MenuBuilderMenuItemNotFoundException
  */
 public function getLeafMenuItem($leaf = null)
 {
     // Get the leaf menu item from the value passed in.
     try {
         $leaf = $this->getMenuItem($leaf);
         return $leaf;
     } catch (MenuBuilderMenuItemNotFoundException $ex) {
         // Eat the exception as we want a chance to find it from the current route.
     }
     // find by current URL...
     $currentUrl = $this->getCurrentUrl();
     $leaf = Menu::where('url', $currentUrl)->first();
     if ($leaf instanceof Menu) {
         return $leaf;
     }
     // Could not find the requested menu item, throwing an exception.
     throw new MenuBuilderMenuItemNotFoundException("Menu item [" . $leaf . "] not found for URL [" . $currentUrl . "].");
 }
Exemplo n.º 4
0
 /**
  * @param Request $request
  * @return mixed
  */
 public function getData(Request $request)
 {
     $id = $request->input('id');
     $menuItem = Menu::with('parent')->find($id);
     return $menuItem;
 }