Skip to content

Commit 1ab2ac7

Browse files
committed
Update Node.php
Fixed scopeLimitDepth for correct work with ancestors() and SQL BETWEEN (first min, second max)
1 parent b868b70 commit 1ab2ac7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Baum/Node.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,9 @@ public function scopeWithoutRoot($query) {
500500
public function scopeLimitDepth($query, $limit) {
501501
$depth = $this->exists ? $this->getDepth() : $this->getLevel();
502502
$max = $depth + $limit;
503+
$scopes = array($depth, $max);
503504

504-
return $query->whereBetween($this->getDepthColumnName(), array($depth, $max));
505+
return $query->whereBetween($this->getDepthColumnName(), array(min($scopes), max($scopes)));
505506
}
506507

507508
/**

0 commit comments

Comments
 (0)