Example #1
0
 /**
  * @return Collection
  */
 public function generateMenu()
 {
     $menu = new Collection();
     if (!$this->auth->getUser()) {
         return $menu;
     }
     if (config('shapeshifter.menu')) {
         foreach (config('shapeshifter.menu') as $item) {
             $item = $this->parseItem($item);
             $menu->push($item);
         }
     } else {
         foreach ($this->modules->getOrdered() as $module) {
             $attributes = $module->json()->getAttributes();
             $item = $this->parseItem($attributes);
             $menu->push($item);
         }
     }
     return $menu->filter(function ($item) {
         return $this->hasAccessToRoute($item['route']);
     })->map(function ($item) {
         $item['children'] = array_filter($item['children'], function ($item) {
             return $this->hasAccessToRoute($item['route']);
         });
         return $item;
     })->filter(function ($item) {
         return $this->hasAccessToRoute('superuser') || count($item['children']) === 0 && $item['route'] !== null;
     });
 }
Example #2
0
 /**
  * Build your sidebar implementation here.
  */
 public function build()
 {
     foreach ($this->modules->enabled() as $module) {
         $name = studly_case($module->getName());
         $class = 'Modules\\' . $name . '\\MenuExtenders\\SidebarExtender';
         if (class_exists($class)) {
             $extender = $this->container->make($class);
             $this->menu->add($extender->extendWith($this->menu));
         }
     }
 }
Example #3
0
 /**
  * Build the menu structure.
  *
  * @return mixed
  */
 public function getItemProviders()
 {
     foreach ($this->modules->enabled() as $module) {
         $name = studly_case($module->getName());
         $class = 'Modules\\' . $name . '\\MenuExtenders\\MenuExtender';
         if (class_exists($class)) {
             $extender = $this->container->make($class);
             $this->extenders->put($module->getName(), ['content' => $extender->getContentItems(), 'static' => $extender->getStaticItems()]);
         }
     }
     return $this->extenders;
 }