public function moveLeft()
{
// 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 leftmost node?
$parentNode = $this->getParent();
if ($parentNode->lft == $this->lft - 1) {
return $this;
}
// Get the sibling to the left
$db = $this->getDbo();
$leftSibling = $this->getClone()->reset()->whereRaw($db->qn($this->getFieldAlias('rgt')) . ' = ' . $db->q($this->lft - 1))->firstOrFail();
// Move the node
return $this->moveToLeftOf($leftSibling);
}