Baum\Node::scopeLimitDepth PHP Method

scopeLimitDepth() public method

Provides a depth level limit for the query.
public scopeLimitDepth ( $query, $limit ) : Builder
return Illuminate\Database\Query\Builder
    public function scopeLimitDepth($query, $limit)
    {
        $depth = $this->exists ? $this->getDepth() : $this->getLevel();
        $max = $depth + $limit;
        $scopes = [$depth, $max];
        return $query->whereBetween($this->getDepthColumnName(), [min($scopes), max($scopes)]);
    }