/**
  * @param Item $item
  *
  * @return bool
  */
 public function isActive(Item $item)
 {
     // Check if one of the children is active
     foreach ($item->getItems() as $item) {
         if ($this->isActive($item)) {
             return true;
         }
     }
     // Custom set active path
     if ($path = $item->getActiveWhen()) {
         return Request::is($path);
     }
     $path = ltrim(str_replace(url('/'), '', $item->getUrl()), '/');
     return Request::is($path, $path . '/*');
 }
 /**
  * @param Item $item
  *
  * @return \Illuminate\Contracts\View\View
  */
 public function render(Item $item)
 {
     if ($item->isAuthorized()) {
         $items = [];
         foreach ($item->getItems() as $child) {
             $items[] = (new IlluminateItemRenderer($this->factory))->render($child);
         }
         $badges = [];
         foreach ($item->getBadges() as $badge) {
             $badges[] = (new IlluminateBadgeRenderer($this->factory))->render($badge);
         }
         $appends = [];
         foreach ($item->getAppends() as $append) {
             $appends[] = (new IlluminateAppendRenderer($this->factory))->render($append);
         }
         return $this->factory->make($this->view, ['item' => $item, 'items' => $items, 'badges' => $badges, 'appends' => $appends, 'active' => (new ActiveStateChecker())->isActive($item)])->render();
     }
 }