本文整理汇总了PHP中MenuItem::create方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::create方法的具体用法?PHP MenuItem::create怎么用?PHP MenuItem::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$array = array(['name' => 'Peluang Bisnis', 'link' => 'peluang', 'order' => '0', 'menu_id' => '1', 'visible' => '1'], ['name' => 'Artikel', 'link' => 'kategori/uncategorized', 'order' => '1', 'menu_id' => '1', 'visible' => '1'], ['name' => 'Syarat & Ketentuan', 'link' => 'pages/syarat-ketentuan', 'order' => '0', 'menu_id' => '2', 'visible' => '1'], ['name' => 'Privacy Policy', 'link' => 'pages/privacy-policy', 'order' => '1', 'menu_id' => '2', 'visible' => '1'], ['name' => 'Disclaimer', 'link' => 'pages/disclaimer', 'order' => '2', 'menu_id' => '2', 'visible' => '1']);
foreach ($array as $item) {
MenuItem::create($item);
}
}
示例2: store
/**
* Store a newly created resource in storage.
* POST /menuitems
*
* @return Response
*/
public function store()
{
// tergantung tipe menu apa yang ingin disimpan, perilaku setiap tipe berbeda prosesnya
$type = Input::get('menuitem_type');
if ($type == 'page') {
$inputdata = Input::all();
$menu_id = $inputdata['menu_id'];
foreach ($inputdata['menuitems'] as $menuitem) {
if (isset($menuitem['id'])) {
$type = $menuitem['type'];
$id = $menuitem['id'];
// Set the item data based on type, manual code currently for each type. Refer to routes.
if ($type == 'page') {
$page = Page::find($id);
$itemdata['name'] = $page->title;
$itemdata['link'] = 'pages/' . $page->slug;
$itemdata['menu_id'] = $menu_id;
}
// Validate and crate the data
$validator = Validator::make($itemdata, MenuItem::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
MenuItem::create($itemdata);
}
}
}
if ($type == 'custom') {
$validator = Validator::make(Input::all(), MenuItem::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
MenuItem::create(Input::except('menuitem_type'));
}
return Redirect::route('admin.menus.index')->with("message", "Data berhasil disimpan");
}
示例3: testInsertionToParentFromOtherScope
public function testInsertionToParentFromOtherScope()
{
$node = MenuItem::create(['menu_id' => 2, 'parent_id' => 5]);
}
示例4: MenuItem
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
require 'config.php';
require 'models/menu-item.class.php';
$menuItem = new MenuItem();
if (isset($_POST["delete_id"])) {
$id = $_POST['delete_id'];
$menuItem->delete($id);
} else {
if (isset($_POST['id'])) {
$name = $_POST['name'];
$description = $_POST['description'];
$price = $_POST['price'];
$id = $_POST['id'];
$menuItem->update($id, $name, $description, $price, 'lunch');
} else {
if (isset($_POST['add'])) {
$name = $_POST['name'];
$description = $_POST['description'];
$price = $_POST['price'];
$menuItem->create($name, $description, $price, 'lunch');
}
}
}