/** * @param Node $parent * @return array */ protected function compileAllowedNodeTypes(Node $parent = null) { $nodeTypes = NodeType::whereVisible(1)->forNodes()->lists('label', 'id')->toArray(); if ($parent) { $allowed = json_decode($parent->getNodeType()->allowed_children); if (count($allowed)) { foreach ($nodeTypes as $key => $value) { if (!in_array($key, $allowed)) { unset($nodeTypes[$key]); } } } } return $nodeTypes; }