public function update_child($nodes, $parent_id = 0) { if (is_array($nodes) and !empty($nodes)) { foreach ($nodes as $order => $node) { $link = Navigation\Model\Link::find($node['id']); $link->parent = $parent_id; $link->order = $order; $link->save(); if (!empty($node['children'])) { $this->update_child($node['children'], $node['id']); } } } }