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