1 | <?php namespace Arcanedev\LaravelNestedSet\Eloquent; |
||
14 | class Collection extends EloquentCollection |
||
15 | { |
||
16 | /* ------------------------------------------------------------------------------------------------ |
||
17 | | Main Functions |
||
18 | | ------------------------------------------------------------------------------------------------ |
||
19 | */ |
||
20 | /** |
||
21 | * Fill `parent` and `children` relationships for every node in the collection. |
||
22 | * |
||
23 | * This will overwrite any previously set relations. |
||
24 | * |
||
25 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
26 | */ |
||
27 | 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 \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
58 | */ |
||
59 | 20 | public function toTree($root = false) |
|
77 | |||
78 | /** |
||
79 | * Build a list of nodes that retain the order that they were pulled from the database. |
||
80 | * |
||
81 | * @param bool $root |
||
82 | * |
||
83 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
84 | */ |
||
85 | 4 | public function toFlatTree($root = false) |
|
96 | |||
97 | /* ------------------------------------------------------------------------------------------------ |
||
98 | | Other Functions |
||
99 | | ------------------------------------------------------------------------------------------------ |
||
100 | */ |
||
101 | /** |
||
102 | * Get root node id. |
||
103 | * |
||
104 | * @param mixed $root |
||
105 | * |
||
106 | * @return int |
||
107 | */ |
||
108 | 24 | protected function getRootNodeId($root = false) |
|
130 | |||
131 | /** |
||
132 | * Flatten a tree into a non recursive array. |
||
133 | * |
||
134 | * @param \Illuminate\Support\Collection $groupedNodes |
||
135 | * @param mixed $parentId |
||
136 | * |
||
137 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
138 | */ |
||
139 | 4 | protected function flattenTree(BaseCollection $groupedNodes, $parentId) |
|
149 | } |
||
150 |