本文整理匯總了PHP中Node::all方法的典型用法代碼示例。如果您正苦於以下問題:PHP Node::all方法的具體用法?PHP Node::all怎麽用?PHP Node::all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Node
的用法示例。
在下文中一共展示了Node::all方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: allLevelUp
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: allLevelUp
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: array
<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: index
public function index()
{
$nodes = Node::all();
return View::make('nodes.index', compact('nodes'));
}