Skip to content

Commit b544b75

Browse files
author
Jelle Spekken
committed
siblingAndSelf method added
1 parent cfbcc29 commit b544b75

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/NodeTrait.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,29 @@ public function siblings()
287287
->where($this->getParentIdName(), '=', $this->getParentId());
288288
}
289289

290+
/**
291+
* Get the node siblings and the node itself.
292+
*
293+
* @return \Kalnoy\Nestedset\QueryBuilder
294+
*/
295+
public function siblingsAndSelf()
296+
{
297+
return $this->newScopedQuery()
298+
->where($this->getParentIdName(), '=', $this->getParentId());
299+
}
300+
301+
/**
302+
* Get query for the node siblings and the node itself.
303+
*
304+
* @param array $columns
305+
*
306+
* @return \Illuminate\Database\Eloquent\Collection
307+
*/
308+
public function getSiblingsAndSelf(array $columns = [ '*' ])
309+
{
310+
return $this->siblingsAndSelf()->get($columns);
311+
}
312+
290313
/**
291314
* Get query for siblings after the node.
292315
*

0 commit comments

Comments
 (0)