本文整理汇总了PHP中app\Menu::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::save方法的具体用法?PHP Menu::save怎么用?PHP Menu::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Menu
的用法示例。
在下文中一共展示了Menu::save方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
DB::transaction(function () use($request) {
//1. Validation
$this->validate($request, ['title' => 'required|unique:menu_translations', 'position' => 'required', 'type' => 'required', 'status' => 'required', 'parent_id' => 'numeric', 'ordering' => 'required|numeric']);
//2. GET ALL REQUESTS AND CREATE MENU OBJECT
$input = $request->all();
if ($request->input('parent_id') == '') {
$input = $request->except('parent_id');
} else {
$menuParent = Menu::find($request->input('parent_id'));
$input['level'] = ++$menuParent->level;
}
$menu = new Menu($input);
//3. SET CREATED USER TO THE MENU
$menu->updatedBy()->associate(Auth::user());
$menu->createdby()->associate(Auth::user());
//4. SAVE MENU
$menu->save();
//$menuTranslations = new MenuTranslation($request->all());
//$menu->menuTranslation()->save($menuTranslations);
//3. INSERT INTO MENUS TABLE
//Menu::create($input);
//Menu::fill($input)->save();
//5. FLASH MESSAGE BACK
Session::flash('flash_message', 'Menu successfully added!');
//6. REDIRECT BACK
});
return redirect()->back();
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(MenuCreateRequest $request)
{
$menu = new Menu();
foreach (array_keys($this->fields) as $field) {
$menu->{$field} = $request->get($field);
}
$menu->save();
return redirect('/admin/menu')->withSuccess("The menu '{$menu->menu}' was created.");
}
示例3: add
public function add()
{
$input = Request::all();
$menu = new Menu();
$menu->menu = $input['menu_nombre'];
$menu->url = $input['menu_url'];
$menu->padre_id = $input['menu_padre_id'];
$menu->save();
return redirect('listMenu');
//->back();
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$menu = new Menu();
$menu->name = $request->name;
$menu->role = $request->role;
$menu->route = $request->route;
$menu->permission = $request->is_main == 'on' ? 0 : $request->permission;
$menu->is_main = $request->is_main == 'on' ? 1 : 0;
$menu->parent = $request->is_main == 'on' ? 0 : $request->parent;
$menu->icon = $request->is_main == 'on' ? $request->icon : 0;
$menu->save();
}
示例5: doCreate
/**
*
*/
public function doCreate()
{
$mname = Input::get('mname');
// Insert to table: menu
$menu = new Menu();
$menu->mname = $mname;
$menu->uid = Session('rak_tea.uid');
$menu->save();
// Insert to table:menu_item
foreach (Input::get('imname') as $imname) {
MenuItem::insert(['imname' => $imname, 'mid' => $menu->mid]);
}
return redirect()->route('/teabreak/menu');
}
示例6: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$slug = Slug::create(['name' => $this->request->slug, 'slug_attribute_id' => self::SLUG_ATTRIBUTE_MENU]);
$this->request['slug_id'] = $slug->id;
$menu = new Menu($this->request->all());
$menu->generateOrder();
if ($menu->location_id == 0) {
$parent = Menu::findOrFail($menu->parent_id);
$menu->location_id = $parent->location_id;
}
$menu->save();
Activity::create(['text' => $this->auth->linkedName() . ' created new menu named ' . $menu->linkedName(), 'user_id' => $this->auth->id]);
Session::flash('flash_message', 'Your menu has been created!');
}
示例7: scrape5CMenu
public function scrape5CMenu()
{
$client = new Client();
$crawler = $client->request('GET', 'https://aspc.pomona.edu/menu/');
$status_code = $client->getResponse()->getStatus();
if ($status_code == 200) {
echo '200 OK<br>';
}
$date = substr(Carbon::today(), 0, 10);
$crawler->filter('table')->last()->filter('tr')->each(function ($row) use($date) {
$count = 0;
$row->filter('td ul')->each(function ($node, $count) use($date) {
$diningHall = substr($node->parents()->parents()->attr('id'), 0, -5);
$node->filter('li')->each(function ($node1) use($count, $diningHall, $date) {
if ($count == 0) {
$meal = 'breakfast';
} elseif ($count == 1) {
$meal = 'lunch';
} else {
$meal = 'dinner';
}
$food = $node1->text();
echo "For " . $meal . " we have " . $food . " at " . $diningHall;
echo "<br>";
$count++;
$store_id = DB::table('stores')->where('sh_name', $diningHall)->value('store_id');
$id = DB::table('email_articles')->where('post_date', $date)->value('article_id');
if (Menu::where('foodName', $food)->where('meal', '=', $meal)->where('article_id', $id)->where('store_id', $store_id)->exists()) {
echo $food . " already exists for " . $meal . " on" . $date;
} else {
$entry = new Menu();
$entry->article_id = $id;
$entry->store_id = $store_id;
$entry->foodName = $food;
$entry->meal = $meal;
$entry->save();
echo $food . " saved for " . $diningHall . " id " . $store_id;
}
});
});
});
}
示例8: addMenu
public function addMenu()
{
$level = (int) Input::get('level');
$name = Input::get('val');
$slug = preg_replace("/[^a-zA-Z0-9]/", "", $name);
$counter = 1;
while ($slug) {
$menu = Menu::where('slug', $slug);
if (!$menu->exists()) {
$mn = new Menu();
$mn->slug = strtolower($slug);
$mn->title = ucwords($name);
$mn->parent = Input::get('id');
$mn->level = ++$level;
$mn->save();
break;
} else {
$slug .= '_' . $counter;
}
}
return 1;
}
示例9: postAdd
/**
* 添加菜单--入库
*
* @param
*
* @author wen.zhou@bioon.com
*
* @date 2015-10-18 12:19:40
*
* @return
*/
public function postAdd()
{
$returnData = ['status' => false, 'msg' => '数据丢失'];
/*添加菜单*/
$menu = new Menu();
$menu->name = request('name', '');
$menu->description = request('description', '');
$menu->slug = request('slug', '');
$menu->url = request('url', '');
$menu->parent_id = request('parent_id', 0);
$add_bool = $menu->save();
if ($add_bool) {
$returnData = ['status' => true, 'msg' => '修改成功'];
} else {
$returnData = ['status' => true, 'msg' => '修改成功'];
}
return response()->json($returnData);
}
示例10: postSimpan
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function postSimpan(Request $request)
{
$jenis = $request->tipe;
$Max_urut = Menu::where('parent_id', $request->parent_id)->where('lokasi', $request->lokasi)->max('urutan');
$urutan = $Max_urut + 1;
$id_arr = [];
$judul_arr = [];
$link_arr = [];
if ($jenis == "Kategori" || $jenis == "Halaman") {
foreach ($request->arr_value as $Val) {
if ($jenis == "Kategori") {
$Data = Kategori::find($Val);
$link = url('/blog/Kategori') . "/" . $Data->slug;
$judul = $Data->nama_kategori;
$judul_arr[] = $judul;
$link_arr[] = $link;
} else {
$Data = Page::find($Val);
$link = url('/page') . "/" . $Data->slug;
$judul = $Data->judul;
$judul_arr[] = $judul;
$link_arr[] = $link;
}
$Menu = new Menu();
$Menu->judul = $judul;
$Menu->link = $link;
$Menu->parent_id = $request->parent_id;
$Menu->urutan = $urutan;
$Menu->lokasi = $request->lokasi;
$Menu->jenis = $jenis;
$Menu->save();
$id_arr[] = $Menu->id;
}
} else {
$Menu = new Menu();
$Menu->judul = $request->judul;
$Menu->link = $request->link;
$Menu->parent_id = $request->parent_id;
$Menu->urutan = $urutan;
$Menu->lokasi = $request->lokasi;
$Menu->jenis = $jenis;
$Menu->save();
$id_arr[] = $Menu->id;
}
?>
<?php
$no = 0;
?>
<?php
foreach ($id_arr as $id) {
?>
<?php
$judul_ = $jenis == "Kategori" || $jenis == "Halaman" ? $judul_arr[$no] : $request->judul;
?>
<?php
$link_ = $jenis == "Kategori" || $jenis == "Halaman" ? $link_arr[$no] : $request->link;
?>
<?php
$selector_id = $request->parent_id == 0 ? "" : "2";
?>
<div class="panel panel-default" id="arrayOrder<?php
echo $selector_id;
?>
-<?php
echo $id;
?>
" style="margin-bottom:5px;color:#000">
<div class="panel-heading" style="border:none;background:#eee;">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#primary-menu" href="#menu-<?php
echo $id;
?>
">
<span class='judul'><?php
echo $judul_;
?>
<?php
echo $request->parent_id == 0 ? "" : "<small> Sub Menu</small>";
?>
</span>
<label class="pull-right">
<small><?php
echo $jenis;
?>
</small>
</label>
</a>
</h4>
</div>
//.........这里部分代码省略.........
示例11: postNewMenu
public function postNewMenu()
{
if (\Auth::check()) {
$data = Input::all();
array_pop($data);
$rules = ['menu_name' => 'required', 'content' => 'required'];
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator->errors())->withInput();
} else {
$menu = new Menu();
$menu->menuname = $data['menu_name'];
$menu->content = $data['content'];
$menu->status = 1;
$menu->save();
return redirect('view_menus');
}
} else {
return redirect('login');
}
}
示例12: postUpdateMenu
public function postUpdateMenu(Request $request)
{
$arr_return = array(
"status"=>"error"
);
$id = $request->has('id')?$request->input('id') : 0;
if($id){
$menu = Menu::find($id);
}else{
$menu = new Menu;
}
$menu->name = $request->has('name')?$request->input('name'):'';
$menu->link = $request->has('link')?$request->input('link'):'';
$menu->parent_id = $request->has('parent_id')?$request->input('parent_id'):'';
$menu->icon_class = $request->has('icon_class')?$request->input('icon_class'):'';
$menu->order_no = $request->has('order_no')?$request->input('order_no'):0;
if($menu->save()){
$arr_return['status'] = 'success';
}else{
$arr_return['message'] = 'Saving fail';
}
return $arr_return;
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$top = new Menu();
$top->name = "顶级菜单";
$top->parent_id = 0;
$top->slug = "show.top.menu";
$top->description = "显示顶级菜单";
$top->url = "";
$top->save();
/*菜单*/
$menu = new Menu();
$menu->name = "菜单管理";
$menu->parent_id = $top->id;
$menu->slug = "show.menu.manage";
$menu->description = "显示菜单管理";
$menu->url = "";
$menu->save();
$menulist = new Menu();
$menulist->name = "菜单列表";
$menulist->parent_id = $menu->id;
$menulist->slug = "show.menu.list";
$menulist->description = "显示菜单列表";
$menulist->url = "/menu/list";
$menulist->save();
/*角色*/
$role = new Menu();
$role->name = "角色管理";
$role->parent_id = $top->id;
$role->slug = "show.role.manage";
$role->description = "显示角色管理";
$role->url = "";
$role->save();
$rolelist = new Menu();
$rolelist->name = "角色列表";
$rolelist->parent_id = $role->id;
$rolelist->slug = "show.role.list";
$rolelist->description = "显示角色列表";
$rolelist->url = "/role/list";
$rolelist->save();
/*权限*/
$permission = new Menu();
$permission->name = "权限管理";
$permission->parent_id = $top->id;
$permission->slug = "show.permission.manage";
$permission->description = "显示权限管理";
$permission->url = "";
$permission->save();
$permissionlist = new Menu();
$permissionlist->name = "权限列表";
$permissionlist->parent_id = $permission->id;
$permissionlist->slug = "show.permission.list";
$permissionlist->description = "显示权限列表";
$permissionlist->url = "/permission/list";
$permissionlist->save();
/*用户*/
$user = new Menu();
$user->name = "用户管理";
$user->parent_id = $top->id;
$user->slug = "show.user.manage";
$user->description = "显示用户管理";
$user->url = "";
$user->save();
$userlist = new Menu();
$userlist->name = "用户列表";
$userlist->parent_id = $user->id;
$userlist->slug = "show.user.list";
$userlist->description = "显示用户列表";
$userlist->url = "/user/list";
$userlist->save();
/*文章*/
$article = new Menu();
$article->name = "文章管理";
$article->parent_id = $top->id;
$article->slug = "show.article.manage";
$article->description = "显示文章管理";
$article->url = "";
$article->save();
$articleList = new Menu();
$articleList->name = "文章列表";
$articleList->parent_id = $article->id;
$articleList->slug = "show.article.list";
$articleList->description = "显示文章列表";
$articleList->url = "/article/list";
$articleList->save();
$addArticle = new Menu();
$addArticle->name = "添加文章";
$addArticle->parent_id = $article->id;
$addArticle->slug = "add.articles";
$addArticle->description = "添加";
$addArticle->url = "/article/add";
$addArticle->save();
/*日志*/
$log = new Menu();
$log->name = "日志管理";
$log->parent_id = $top->id;
//.........这里部分代码省略.........
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$top = new Menu();
$top->name = "顶级菜单";
$top->parent_id = 0;
$top->slug = "show.top.menu";
$top->description = "显示顶级菜单";
$top->url = "";
$top->save();
/*菜单*/
$menu = new Menu();
$menu->name = "菜单管理";
$menu->parent_id = $top->id;
$menu->slug = "show.menu.manage";
$menu->description = "显示菜单管理";
$menu->url = "";
$menu->save();
$menulist = new Menu();
$menulist->name = "菜单列表";
$menulist->parent_id = $menu->id;
$menulist->slug = "show.menu.list";
$menulist->description = "显示菜单列表";
$menulist->url = "/menu/list";
$menulist->save();
/*角色*/
$role = new Menu();
$role->name = "角色管理";
$role->parent_id = $top->id;
$role->slug = "show.role.manage";
$role->description = "显示角色管理";
$role->url = "";
$role->save();
$rolelist = new Menu();
$rolelist->name = "角色列表";
$rolelist->parent_id = $role->id;
$rolelist->slug = "show.role.list";
$rolelist->description = "显示角色列表";
$rolelist->url = "/role/list";
$rolelist->save();
/*权限*/
$permission = new Menu();
$permission->name = "权限管理";
$permission->parent_id = $top->id;
$permission->slug = "show.permission.manage";
$permission->description = "显示权限管理";
$permission->url = "";
$permission->save();
$permissionlist = new Menu();
$permissionlist->name = "权限列表";
$permissionlist->parent_id = $permission->id;
$permissionlist->slug = "show.permission.list";
$permissionlist->description = "显示权限列表";
$permissionlist->url = "/permission/list";
$permissionlist->save();
/*用户*/
$user = new Menu();
$user->name = "用户管理";
$user->parent_id = $top->id;
$user->slug = "show.user.manage";
$user->description = "显示用户管理";
$user->url = "";
$user->save();
$userlist = new Menu();
$userlist->name = "用户列表";
$userlist->parent_id = $user->id;
$userlist->slug = "show.user.list";
$userlist->description = "显示用户列表";
$userlist->url = "/user/list";
$userlist->save();
}