File tree 1 file changed +11
-8
lines changed
1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -195,26 +195,29 @@ if ($sibling = $node->nextSiblings()->first())
195
195
}
196
196
```
197
197
198
- Moving up is a little bit trickier :
198
+ Moving up is similar :
199
199
200
200
``` php
201
- if ($sibling = $node->prevSiblings()->reversed()-> first())
201
+ if ($sibling = $node->prevSiblings()->first())
202
202
{
203
203
$node->before($sibling)->save();
204
204
}
205
205
```
206
206
207
- To move node up we need to insert it before node that is right at the top of it.
208
- If we use ` $node->prevSiblings()->first() ` we'll get the first child of the parent
209
- since all nodes are ordered by fixed values. We apply ` reversed() ` scope to reverse
210
- default order.
211
-
212
207
## Advanced usage
213
208
214
209
### Default order
215
210
216
211
Nodes are ordered by lft column unless there is ` limit ` or ` offset ` is provided,
217
- or when user uses ` orderBy ` .
212
+ or when user uses ` orderBy() ` .
213
+
214
+ Reversed order can be applied using ` reversed() ` scope. When using ` prevSiblings() `
215
+ or ` prev() ` reversed order is aplied by default. To use the default order, use
216
+ ` defaultOrder() ` scope:
217
+
218
+ ``` php
219
+ $siblings = $node->prevSiblings()->defaultOrder()->get();
220
+ ```
218
221
219
222
### Custom collection
220
223
You can’t perform that action at this time.
0 commit comments