/**
  * Handle the command.
  *
  * @return array
  */
 public function handle()
 {
     $nav = [];
     /* @var UserInterface $user */
     $user = $this->guard->user();
     /**
      * Loop through the modules and build a navigation
      * array with the basic information available.
      *
      * Keep it generic but helpful.
      */
     foreach ($this->modules->enabled() as $module) {
         /**
          * If the group is set to false then
          * skip it - no backend navigation.
          */
         if ($module instanceof Module && $module->getNavigation() === false) {
             continue;
         }
         /**
          * If the user does not have access to anything
          * in the addon then don't add it to the navigation.
          */
         if ($this->config->get($module->getNamespace('permissions')) && !$user->hasPermission($module->getNamespace('*'))) {
             continue;
         }
         // Build the required data.
         $url = $this->getUrl($module);
         $title = $this->getTitle($module);
         $group = $this->getGroup($module);
         $active = $this->getActive($module);
         $item = compact('url', 'title', 'group', 'active');
         /**
          * If the module defined a $navigation property it
          * get's put into a dropdown of the same name.
          *
          * Otherwise just lop it onto the navigation array.
          */
         if ($group) {
             $this->addItemToGroup($nav, $item, $module);
         } else {
             $this->addItem($nav, $item, $module);
         }
     }
     // Finish up formatting.
     $this->finish($nav);
     return $nav;
 }
 /**
  * Handle the navigation.
  *
  * @param ControlPanelBuilder $builder
  * @param ModuleCollection    $modules
  */
 public function handle(ControlPanelBuilder $builder, ModuleCollection $modules)
 {
     $navigation = [];
     /* @var Module $module */
     foreach ($modules->enabled()->accessible() as $module) {
         if ($module->getNavigation()) {
             $navigation[trans($module->getName())] = $module;
         }
     }
     ksort($navigation);
     foreach ($navigation as $key => $module) {
         if ($module->getNamespace() == 'anomaly.module.dashboard') {
             $navigation = [$key => $module] + $navigation;
             break;
         }
     }
     $builder->setNavigation(array_map(function (Module $module) {
         return ['breadcrumb' => $module->getName(), 'title' => $module->getTitle(), 'slug' => $module->getNamespace(), 'href' => 'admin/' . $module->getSlug()];
     }, $navigation));
 }