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:
142
142
* ` nextSiblings() ` and ` prevSiblings() ` to query nodes after and before the node
143
143
respectively.
144
144
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
+
145
158
Nodes can be provided with _ nesting level_ if scope ` withDepth ` is applied:
146
159
147
160
``` php
@@ -189,7 +202,7 @@ the parent.
189
202
To move node down, this snippet can be used:
190
203
191
204
``` php
192
- if ($sibling = $node->nextSiblings()->first ())
205
+ if ($sibling = $node->getNextSibling ())
193
206
{
194
207
$node->after($sibling)->save();
195
208
}
@@ -198,7 +211,7 @@ if ($sibling = $node->nextSiblings()->first())
198
211
Moving up is similar:
199
212
200
213
``` php
201
- if ($sibling = $node->prevSiblings()->first ())
214
+ if ($sibling = $node->getPrevSibling ())
202
215
{
203
216
$node->before($sibling)->save();
204
217
}
Original file line number Diff line number Diff line change @@ -759,6 +759,18 @@ public function getDescendants(array $columns = array('*'))
759
759
return $ this ->descendants ()->get ($ columns );
760
760
}
761
761
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
+
762
774
/**
763
775
* Shorthand for nextSiblings().
764
776
*
You can’t perform that action at this time.
0 commit comments