Skip to content

Commit

Permalink
Merge pull request #11 from P4BGroup/feat/fixes
Browse files Browse the repository at this point in the history
hotfix/rebuild-tree
  • Loading branch information
Flaviu Chelaru authored Jan 14, 2020
2 parents 4f46189 + 81690f7 commit d01850e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ public function processUpdate(ModelInterface $model): void

$right = $parentModel->readAttribute(self::$rightKey);
$depth = $parentModel->readAttribute(self::$depthKey);
if (
$parentModel->readAttribute(self::$rightKey) > $currentModel->readAttribute(self::$rightKey)
if ($currentModel->readAttribute(self::$rightKey) == 0) {
$right = $parentModel->readAttribute(self::$rightKey);
$depth = $parentModel->readAttribute(self::$depthKey) + 1;
} elseif ($parentModel->readAttribute(self::$rightKey) > $currentModel->readAttribute(self::$rightKey)
&& $parentModel->readAttribute(self::$rightKey) > $currentModel->readAttribute(self::$leftKey)
) {
$right = $parentModel->readAttribute(self::$rightKey) - 2;
Expand Down

0 comments on commit d01850e

Please sign in to comment.