/**
  * Handle the command.
  */
 public function handle(LinkRepositoryInterface $links)
 {
     /* @var LinkInterface $link */
     foreach ($this->link->getChildren() as $link) {
         $links->save($link->setParentId(null));
     }
 }
 /**
  * Return only children of the provided item.
  *
  * @param LinkInterface $parent
  * @return LinkCollection
  */
 public function children(LinkInterface $parent)
 {
     $children = [];
     /* @var LinkInterface $item */
     foreach ($this->items as $item) {
         if ($item->getParentId() == $parent->getId()) {
             $children[] = $item;
         }
     }
     return new static($children);
 }
 /**
  * Return if the link is enabled or not.
  *
  * @param  LinkInterface $link
  * @return bool
  */
 public function enabled(LinkInterface $link)
 {
     /* @var PageLinkTypeModel $entry */
     /* @var PageInterface $page */
     $entry = $link->getEntry();
     $page = $entry->getPage();
     if ($page) {
         return $page->isEnabled();
     }
     return false;
 }
 /**
  * Return the related children.
  *
  * @return LinkCollection
  */
 public function children()
 {
     return (new Decorator())->decorate($this->object->getChildren());
 }
 /**
  * Return the entry title.
  *
  * @param LinkInterface $link
  * @return string
  */
 public function title(LinkInterface $link)
 {
     return $link->getEntry()->getTitle();
 }
 /**
  * Return if the link exists or not.
  *
  * @param LinkInterface $link
  * @return bool
  */
 public function exists(LinkInterface $link)
 {
     /* @var PageLinkTypeModel $entry */
     $entry = $link->getEntry();
     return (bool) $entry->getPage();
 }