File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,19 @@ There are few more methods:
142142* ` nextSiblings() ` and ` prevSiblings() ` to query nodes after and before the node
143143 respectively.
144144
145+ ` Node ` is provided with few helper methods for quicker access:
146+
147+ * ` getAncestors `
148+ * ` getDescendants `
149+ * ` getSiblings `
150+ * ` getNextSiblings `
151+ * ` getPrevSiblings `
152+ * ` getNextSibling `
153+ * ` getPrevSibling `
154+
155+ Each of this methods accepts array of columns needed to be selected and returns
156+ the result of corresponding query.
157+
145158Nodes can be provided with _ nesting level_ if scope ` withDepth ` is applied:
146159
147160``` php
@@ -189,7 +202,7 @@ the parent.
189202To move node down, this snippet can be used:
190203
191204``` php
192- if ($sibling = $node->nextSiblings()->first ())
205+ if ($sibling = $node->getNextSibling ())
193206{
194207 $node->after($sibling)->save();
195208}
@@ -198,7 +211,7 @@ if ($sibling = $node->nextSiblings()->first())
198211Moving up is similar:
199212
200213``` php
201- if ($sibling = $node->prevSiblings()->first ())
214+ if ($sibling = $node->getPrevSibling ())
202215{
203216 $node->before($sibling)->save();
204217}
Original file line number Diff line number Diff line change @@ -759,6 +759,18 @@ public function getDescendants(array $columns = array('*'))
759759 return $ this ->descendants ()->get ($ columns );
760760 }
761761
762+ /**
763+ * Shorthand for siblings()
764+ *
765+ * @param array $column
766+ *
767+ * @return \Kalnoy\Nestedset\Collection
768+ */
769+ public function getSiblings (array $ column = array ('* ' ))
770+ {
771+ return $ this ->siblings ()->get ($ columns );
772+ }
773+
762774 /**
763775 * Shorthand for nextSiblings().
764776 *
You can’t perform that action at this time.
0 commit comments