public function moveRight()
{
// Sanity checks on current node position
if ($this->lft >= $this->rgt) {
throw new TreeInvalidLftRgtCurrent();
}
// If it is a root node we will not move the node (roots don't participate in tree ordering)
if ($this->isRoot()) {
return $this;
}
// Are we already the rightmost node?
$parentNode = $this->getParent();
if ($parentNode->rgt == $this->rgt + 1) {
return $this;
}
// Get the sibling to the right
$db = $this->getDbo();
$rightSibling = $this->getClone()->reset()->whereRaw($db->qn($this->getFieldAlias('lft')) . ' = ' . $db->q($this->rgt + 1))->firstOrFail();
// Move the node
return $this->moveToRightOf($rightSibling);
}