Skip to content

Commit

Permalink
Fix error in scope
Browse files Browse the repository at this point in the history
* fix error in scope
  • Loading branch information
pvsaintpe authored Oct 23, 2019
1 parent 3efe7b0 commit ea1c372
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Traits/LTreeModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ public function renderAsLtree($value, $pad_string = LTreeHelper::PAD_STRING, $pa

public function getAncestorByLevel(int $level = 1)
{
return static::scopeAncestorByLevel($level)->first();
return static::ancestorByLevel($level)->first();
}

public function scopeAncestorByLevel(Builder $query, int $level = 1): Builder
{
return $query->whereRaw(sprintf(
"({$this->getLtreePathColumn()} @> text2ltree('%s')) and nlevel(path) = %d",
LTreeHelper::pathAsString($this->getLtreePath()),
$level)
"({$this->getLtreePathColumn()} @> text2ltree('%s')) and nlevel(path) = %d",
LTreeHelper::pathAsString($this->getLtreePath()),
$level)
);
}
}

0 comments on commit ea1c372

Please sign in to comment.