1 | <?php namespace Arcanedev\LaravelNestedSet\Eloquent; |
||
14 | class Collection extends EloquentCollection |
||
15 | { |
||
16 | /** |
||
17 | * Fill `parent` and `children` relationships for every node in the collection. |
||
18 | * |
||
19 | * This will overwrite any previously set relations. |
||
20 | * |
||
21 | * @return $this |
||
22 | */ |
||
23 | 20 | public function linkNodes() |
|
49 | |||
50 | /** |
||
51 | * Build a tree from a list of nodes. Each item will have set children relation. |
||
52 | * To successfully build tree "id", "_lft" and "parent_id" keys must present. |
||
53 | * If `$root` is provided, the tree will contain only descendants of that node. |
||
54 | * |
||
55 | * @param mixed $root |
||
56 | * |
||
57 | * @return self |
||
58 | */ |
||
59 | 20 | public function toTree($root = false) |
|
80 | |||
81 | /** |
||
82 | * Get root node id. |
||
83 | * |
||
84 | * @param mixed $root |
||
85 | * |
||
86 | * @return int |
||
87 | */ |
||
88 | 20 | protected function getRootNodeId($root) |
|
112 | |||
113 | /** |
||
114 | * Build a list of nodes that retain the order that they were pulled from the database. |
||
115 | * |
||
116 | * @return self |
||
117 | */ |
||
118 | public function toFlattenedTree() |
||
122 | |||
123 | /** |
||
124 | * Flatten a tree into a non recursive array |
||
125 | */ |
||
126 | public function flattenTree() |
||
136 | |||
137 | /* ------------------------------------------------------------------------------------------------ |
||
138 | | Other Functions |
||
139 | | ------------------------------------------------------------------------------------------------ |
||
140 | */ |
||
141 | /** |
||
142 | * Flatten a single node |
||
143 | * |
||
144 | * @param \Arcanedev\LaravelNestedSet\NodeTrait $node |
||
|
|||
145 | * |
||
146 | * @return array |
||
147 | */ |
||
148 | protected function flattenNode($node) |
||
159 | } |
||
160 |