Пример #1
0
 public static function allLevelUp($excellent = false)
 {
     $nodes = Node::all();
     $result = array();
     foreach ($nodes as $key => $node) {
         if ($node->parent_node == null) {
             $result['top'][] = $node;
         } else {
             if ($excellent) {
                 $node->excellent && ($result['second'][$node->parent_node][] = $node);
             } else {
                 $result['second'][$node->parent_node][] = $node;
             }
         }
     }
     return $result;
 }
Пример #2
0
 public static function allLevelUp()
 {
     return Cache::remember(self::CACHE_KEY, self::CACHE_MINUTES, function () {
         $nodes = Node::all();
         $result = array();
         foreach ($nodes as $key => $node) {
             if ($node->parent_node == null) {
                 $result['top'][] = $node;
                 foreach ($nodes as $skey => $snode) {
                     if ($snode->parent_node == $node->id) {
                         $result['second'][$node->id][] = $snode;
                     }
                 }
             }
         }
         return $result;
     });
 }
Пример #3
0
<h2>Add Menu Item</h2>

<p>Adding to menu <?php 
echo $this->model->name;
?>
</p>

<form action="/menu_item/create" method="POST">
<?php 
echo $this->input_for('menu_id', '', array('type' => 'hidden', 'value' => $this->model->id));
echo $this->input_for('name', 'Name');
?>
<hr />
<?php 
echo $this->input_for('url', 'Enter a URL');
?>
<p><strong>OR</strong></p>
<?php 
echo $this->input_for('node_id', 'Choose existing content', array('type' => 'list', 'options' => $this->model_options(Node::all(), 'id', '{title} - {type} - {slug}')));
?>
<hr />
<?php 
echo $this->input_for('parent_id', 'Parent', array('type' => 'list', 'options' => $this->model_options($this->model->all_items, 'id', 'name')));
?>
<input type="submit" value="Save" />
</form>
Пример #4
0
 public function index()
 {
     $nodes = Node::all();
     return View::make('nodes.index', compact('nodes'));
 }