/** * Renders the specified category and it's children in single dimension array. * * @param Node $node * * @return array */ public static function getRenderedNode(Node $node) { $options = []; if ($node->isRoot()) { $name = $node->name; } else { $depth = str_repeat('--', $node->depth); $name = sprintf('%s %s', $depth, $node->name); } $options[$node->id] = $name; if ($node->children()->count() > 0) { foreach ($node->children as $child) { $options = $options + static::getRenderedNode($child); } } return $options; }