Exemplo n.º 1
0
 /**
  * Return an key-value array indicating the node's depth with $seperator.
  *
  * @return array
  */
 public static function getNestedList($column, $key = null, $seperator = ' ')
 {
     $instance = new static();
     $key = $key ?: $instance->getKeyName();
     $depthColumn = $instance->getDepthColumnName();
     $nodes = $instance->newNestedSetQuery()->visible()->get()->toArray();
     return array_combine(array_map(function ($node) use($key) {
         return $node[$key];
     }, $nodes), array_map(function ($node) use($seperator, $depthColumn, $column) {
         return str_repeat($seperator, $node[$depthColumn]) . $node[$column];
     }, $nodes));
 }
Exemplo n.º 2
0
 public static function getMenuSortableNode()
 {
     $instance = new static();
     $nodes = $instance->newNestedSetQuery();
     $nodes = $nodes->get()->toHierarchy();
     //        $nodes = $nodes->whereStatus(1)->get()->toHierarchy();
     //echo '<pre>';
     //print_r($nodes);
     //die;
     $output = '<ol class="sortable ui-sortable">';
     $output .= static::renderMenuSortableNode($nodes);
     $output .= '</ol>';
     return $output;
 }