/** * Handle the command. */ public function handle(ViewTemplate $template) { if (!($current = $this->pages->current())) { return; } if (!$current->getParentId()) { return; } /* @var PageInterface $page */ foreach ($this->pages as $page) { /** * Already flagged. */ if ($page->isActive() || $page->isCurrent()) { continue; } /** * Set active if the direct * parent of current page. */ if ($page->getId() == $current->getParentId()) { $page->setActive(true); } /** * If the active page is in the children * of this page then mark it active too. */ if (!$this->pages->children($page)->active()->isEmpty()) { $page->setActive(true); $this->dispatch(new SetActivePages($this->pages)); } } }
/** * Handle the command. */ public function handle() { /* @var PageInterface|EloquentModel $page */ foreach ($this->pages as $page) { $page->setRelation('children', $this->pages->children($page)); } }