当前位置: 首页>>代码示例>>PHP>>正文


PHP Menu::create方法代码示例

本文整理汇总了PHP中app\models\Menu::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::create方法的具体用法?PHP Menu::create怎么用?PHP Menu::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Menu的用法示例。


在下文中一共展示了Menu::create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(\App\Http\Requests\CreateMenuRequest $request)
 {
     //
     $menu = \App\Models\Menu::create($request->all());
     $menu->save();
     return redirect('menus');
 }
开发者ID:skalata90,项目名称:bellamilano,代码行数:13,代码来源:MenusController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Menu::create(['key' => '', 'name' => 'Главная', 'sort' => '1']);
     Menu::create(['key' => 'catalog', 'name' => 'Каталог', 'sort' => '2']);
     Menu::create(['key' => 'delivery', 'name' => 'Доставка и оплата', 'sort' => '3']);
     Menu::create(['key' => 'orderFurniture', 'name' => 'Мебель на заказ', 'sort' => '4']);
     Menu::create(['key' => 'wholesalers', 'name' => 'Оптовикам', 'sort' => '5']);
     Menu::create(['key' => 'contacts', 'name' => 'Контакты', 'sort' => '6']);
 }
开发者ID:pechatny,项目名称:kolizej,代码行数:14,代码来源:MenuTableSeeder.php

示例3: store

 public function store(StoreMenuPostRequest $request)
 {
     $input = $request->all();
     //$input['user_id'] = $this->login_user->id;
     $res = Menu::create($input);
     if ($res) {
         flash()->success('操作成功');
     } else {
         flash()->error('操作失败');
     }
     return redirect()->back();
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:12,代码来源:MenuController.php

示例4: menuNew

 public function menuNew(Menu $menuModel = null, Page $pageModel = null, Request $request = null)
 {
     if (request()->isMethod('POST')) {
         $menuModel->create($request->all());
         return redirect()->route('admin.menu');
     } else {
         $menu = Menu::where('pid', '=', 0)->get();
         $top_menu = array(0 => '--Корневое--');
         foreach ($menu as $item) {
             $top_menu[$item->id] = $item->name;
         }
         $pagesData = $pageModel::all();
         $pages = array(0 => '--Выберите страницу--');
         foreach ($pagesData as $page) {
             $pages[$page->url] = $page->title;
         }
         return view('admin.menu.new', ['topmenu' => $top_menu, 'pages' => $pages]);
     }
 }
开发者ID:Comrada,项目名称:laravel-cms,代码行数:19,代码来源:AdminController.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // TODO: Remove this before release...
     // Look for and delete route named 'do-not-pre-load' if it exist.
     // That route is used to test a failure with the Authorization middleware and should not be loaded automatically.
     $routeToDelete = Route::where('name', 'test-acl.do-not-pre-load')->get()->first();
     if ($routeToDelete) {
         Route::destroy($routeToDelete->id);
     }
     $testUserOne = User::create(['username' => 'user1', 'first_name' => 'User', 'last_name' => 'One', 'email' => 'user1@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserTwo = User::create(['username' => 'user2', 'first_name' => 'User', 'last_name' => 'Two', 'email' => 'user2@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserThree = User::create(['username' => 'user3', 'first_name' => 'User', 'last_name' => 'Three', 'email' => 'user3@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserFour = User::create(['username' => 'user4', 'first_name' => 'User', 'last_name' => 'Four', 'email' => 'user4@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserFive = User::create(['username' => 'user5', 'first_name' => 'User', 'last_name' => 'Five', 'email' => 'user5@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserSix = User::create(['username' => 'user6', 'first_name' => 'User', 'last_name' => 'Six', 'email' => 'user6@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserSeven = User::create(['username' => 'user7', 'first_name' => 'User', 'last_name' => 'Seven', 'email' => 'user7@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserEight = User::create(['username' => 'user8', 'first_name' => 'User', 'last_name' => 'Eight', 'email' => 'user8@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserNine = User::create(['username' => 'user9', 'first_name' => 'User', 'last_name' => 'Nine', 'email' => 'user9@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserTen = User::create(['username' => 'user10', 'first_name' => 'User', 'last_name' => 'Ten', 'email' => 'user10@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserEleven = User::create(['username' => 'user11', 'first_name' => 'User', 'last_name' => 'Eleven', 'email' => 'user11@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserTwelve = User::create(['username' => 'user12', 'first_name' => 'User', 'last_name' => 'Twelve', 'email' => 'user12@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserThirteen = User::create(['username' => 'user13', 'first_name' => 'User', 'last_name' => 'Thirteen', 'email' => 'user13@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserFourteen = User::create(['username' => 'user14', 'first_name' => 'User', 'last_name' => 'Fourteen', 'email' => 'user14@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     $testUserFifteen = User::create(['username' => 'user15', 'first_name' => 'User', 'last_name' => 'Fifteen', 'email' => 'user15@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
     /////////
     // Create a few test permissions for the flash-test pages.
     $permTestLevelSuccess = Permission::create(['name' => 'test-level-success', 'display_name' => 'Test level success', 'description' => 'Testing level success', 'enabled' => true]);
     $permTestLevelInfo = Permission::create(['name' => 'test-level-info', 'display_name' => 'Test level info', 'description' => 'Testing level info', 'enabled' => true]);
     $permTestLevelWarning = Permission::create(['name' => 'test-level-warning', 'display_name' => 'Test level warning', 'description' => 'Testing level warning', 'enabled' => true]);
     $permTestLevelError = Permission::create(['name' => 'test-level-error', 'display_name' => 'Test level error', 'description' => 'Testing level error', 'enabled' => true]);
     ////////////////////////////////////
     // Create some roles for the flash test pages.
     ////////////////////////////////////
     // Success
     $roleFlashSuccessViewer = Role::create(["name" => "flash-success-viewer", "display_name" => "Flash success viewer", "description" => "Can see the success flash test page.", "enabled" => true]);
     // Assign permission TestLevelSuccess
     $roleFlashSuccessViewer->perms()->attach($permTestLevelSuccess->id);
     // Assign user membership to role
     $roleFlashSuccessViewer->users()->attach($testUserTwo->id);
     // Info
     $roleFlashInfoViewer = Role::create(["name" => "flash-info-viewer", "display_name" => "Flash info viewer", "description" => "Can see the info flash test page.", "enabled" => true]);
     // Assign permission Info and Success to the InfoViewer role.
     $roleFlashInfoViewer->perms()->attach($permTestLevelInfo->id);
     $roleFlashInfoViewer->perms()->attach($permTestLevelSuccess->id);
     // Assign user membership to role
     $roleFlashInfoViewer->users()->attach($testUserThree->id);
     // Warning
     $roleFlashWarningViewer = Role::create(["name" => "flash-warning-viewer", "display_name" => "Flash warning viewer", "description" => "Can see the warning flash test page.", "enabled" => true]);
     // Assign permission Warning, Info and Success to the WarningViewer role.
     $roleFlashWarningViewer->perms()->attach($permTestLevelWarning->id);
     $roleFlashWarningViewer->perms()->attach($permTestLevelInfo->id);
     $roleFlashWarningViewer->perms()->attach($permTestLevelSuccess->id);
     // Assign user membership to role
     $roleFlashWarningViewer->users()->attach($testUserFour->id);
     // Error
     $roleFlashErrorViewer = Role::create(["name" => "flash-error-viewer", "display_name" => "Flash error viewer", "description" => "Can see the error flash test page.", "enabled" => true]);
     // Assign permission Error, Warning, Info and Success to the ErrorViewer role.
     $roleFlashErrorViewer->perms()->attach($permTestLevelError->id);
     $roleFlashErrorViewer->perms()->attach($permTestLevelWarning->id);
     $roleFlashErrorViewer->perms()->attach($permTestLevelInfo->id);
     $roleFlashErrorViewer->perms()->attach($permTestLevelSuccess->id);
     // Assign user membership to role
     $roleFlashErrorViewer->users()->attach($testUserFive->id);
     /////////
     // Find basic-authenticated permission.
     $permBasicAuthenticated = Permission::where('name', 'basic-authenticated')->first();
     // Find guest-only permission.
     $permGuestOnly = Permission::where('name', 'guest-only')->first();
     // Find open-to-all permission.
     $permOpenToAll = Permission::where('name', 'open-to-all')->first();
     // Find admin-settings permission.
     $permAdminSettings = Permission::where('name', 'admin-settings')->first();
     ////////////////////////////////////
     // Associate some permission to acl test routes
     $routeTestACLHome = Route::where('name', 'test-acl.home')->get()->first();
     $routeTestACLHome->permission()->associate($permOpenToAll);
     $routeTestACLHome->save();
     //
     $routeTestACLAdmins = Route::where('name', 'test-acl.admins')->get()->first();
     $routeTestACLAdmins->permission()->associate($permAdminSettings);
     $routeTestACLAdmins->save();
     //
     $routeTestACLBasicAuthenticated = Route::where('name', 'test-acl.basic-authenticated')->get()->first();
     $routeTestACLBasicAuthenticated->permission()->associate($permBasicAuthenticated);
     $routeTestACLBasicAuthenticated->save();
     //
     $routeTestACLGuestOnly = Route::where('name', 'test-acl.guest-only')->get()->first();
     $routeTestACLGuestOnly->permission()->associate($permGuestOnly);
     $routeTestACLGuestOnly->save();
     //
     $routeTestACLOpenToAll = Route::where('name', 'test-acl.open-to-all')->get()->first();
     $routeTestACLOpenToAll->permission()->associate($permOpenToAll);
     $routeTestACLOpenToAll->save();
     ////////////////////////////////////
     // Associate some permission to flash test routes
//.........这里部分代码省略.........
开发者ID:bztrn,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:101,代码来源:DevelopmentSeeder.php

示例6: save

 /**
  * @param Request $request
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function save(Request $request)
 {
     $attributes = $request->all();
     $id = $attributes['id'];
     if ($id) {
         // If $id is not null or blank we must be editing.
         // Locate existing menu item.
         $menuItem = Menu::find($id);
         if (!$menuItem->isEditable()) {
             Flash::warning(trans('admin/menu-builder/menu-builder.update-failed-cant-be-edited', ['id' => $menuItem->id, 'label' => $menuItem->label]));
         } else {
             // Fix issue #23: using the wrong column name in the unique rule.
             // validate attributes.
             $this->validate($request, array('name' => 'required|unique:menus,name,' . $id, 'label' => 'required'));
             // Log action by user.
             Audit::log(Auth::user()->id, trans('admin/menu-builder/menu-builder.audit-log.category'), trans('admin/menu-builder/menu-builder.audit-log.msg-index'));
             // Update menu item.
             $menuItem->update($attributes);
             Flash::success(trans('admin/menu-builder/menu-builder.update-success'));
         }
     } else {
         // else creating new menu item.
         // First unset/remove blank 'id' element from the array, otherwise the insert SQL statement will not
         // include an incremented value for the identity column, but instead the value of id which is
         // blank: ''.
         unset($attributes['id']);
         // Validate attributes.
         $this->validate($request, array('name' => 'required|unique:menus', 'label' => 'required'));
         // Create new menu item.
         $menuItem = Menu::create($attributes);
         Flash::success(trans('admin/menu-builder/menu-builder.create-success'));
     }
     return redirect('/admin/menus');
 }
开发者ID:sroutier,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:39,代码来源:MenusController.php

示例7: run

 public function run()
 {
     Menu::create(['id' => 1, 'name' => 'Advice & Features', 'link' => '#']);
 }
开发者ID:remix101,项目名称:compex,代码行数:4,代码来源:MenusTableSeeder.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     ////////////////////////////////////
     // Load the routes
     Route::loadLaravelRoutes();
     // Look for and delete route named 'do-not-load' if it exist.
     // That route is used to test the Authorization middleware and should not be loaded automatically.
     $routeToDelete = Route::where('name', 'do-not-load')->get()->first();
     if ($routeToDelete) {
         Route::destroy($routeToDelete->id);
     }
     ////////////////////////////////////
     // Create basic set of permissions
     $permGuestOnly = Permission::create(['name' => 'guest-only', 'display_name' => 'Guest only access', 'description' => 'Only guest users can access these.', 'enabled' => true]);
     $permOpenToAll = Permission::create(['name' => 'open-to-all', 'display_name' => 'Open to all', 'description' => 'Everyone can access these, even unauthenticated (guest) users.', 'enabled' => true]);
     $permBasicAuthenticated = Permission::create(['name' => 'basic-authenticated', 'display_name' => 'Basic authenticated', 'description' => 'Basic permission after being authenticated.', 'enabled' => true]);
     // Create a few permissions for the admin|security section
     $permManageMenus = Permission::create(['name' => 'manage-menus', 'display_name' => 'Manage menus', 'description' => 'Allows a user to manage the site menus.', 'enabled' => true]);
     $permManageUsers = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'Allows a user to manage the site users.', 'enabled' => true]);
     $permManageRoles = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'Allows a user to manage the site roles.', 'enabled' => true]);
     $permManagePermissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'Allows a user to manage the site permissions.', 'enabled' => true]);
     $permManageRoutes = Permission::create(['name' => 'manage-routes', 'display_name' => 'Manage routes', 'description' => 'Allows a user to Manage the site routes.', 'enabled' => true]);
     // Create a few permissions for the admin|audit section
     $permAuditLogView = Permission::create(['name' => 'audit-log-view', 'display_name' => 'View audit log', 'description' => 'Allows a user to view the audit log.', 'enabled' => true]);
     $permAuditReplay = Permission::create(['name' => 'audit-log-replay', 'display_name' => 'Replay audit log item', 'description' => 'Allows a user to replay items from the audit log.', 'enabled' => true]);
     $permAuditPurge = Permission::create(['name' => 'audit-log-purge', 'display_name' => 'Purge audit log', 'description' => 'Allows a user to purge old items from the audit log.', 'enabled' => true]);
     $permAdminSettings = Permission::create(['name' => 'admin-settings', 'display_name' => 'Administer site settings', 'description' => 'Allows a user to change site settings.', 'enabled' => true]);
     ////////////////////////////////////
     // Associate open-to-all permission to some routes
     $routeBackslash = Route::where('name', 'backslash')->get()->first();
     $routeBackslash->permission()->associate($permOpenToAll);
     $routeBackslash->save();
     $routeHome = Route::where('name', 'home')->get()->first();
     $routeHome->permission()->associate($permOpenToAll);
     $routeHome->save();
     $routeFaust = Route::where('name', 'faust')->get()->first();
     $routeFaust->permission()->associate($permOpenToAll);
     $routeFaust->save();
     // Associate basic-authenticated permission to the dashboard route
     $routeDashboard = Route::where('name', 'dashboard')->get()->first();
     $routeDashboard->permission()->associate($permBasicAuthenticated);
     $routeDashboard->save();
     // Associate the audit-log permissions
     $routeAuditView = Route::where('name', 'admin.audit.index')->get()->first();
     $routeAuditView->permission()->associate($permAuditLogView);
     $routeAuditView->save();
     $routeAuditShow = Route::where('name', 'admin.audit.show')->get()->first();
     $routeAuditShow->permission()->associate($permAuditLogView);
     $routeAuditShow->save();
     $routeAuditPurge = Route::where('name', 'admin.audit.purge')->get()->first();
     $routeAuditPurge->permission()->associate($permAuditPurge);
     $routeAuditPurge->save();
     $routeAuditReplay = Route::where('name', 'admin.audit.replay')->get()->first();
     $routeAuditReplay->permission()->associate($permAuditReplay);
     $routeAuditReplay->save();
     // Associate manage-menus permissions to routes starting with 'admin.menus.'
     $manageMenusRoutes = Route::where('name', 'like', "admin.menus.%")->get()->all();
     foreach ($manageMenusRoutes as $route) {
         $route->permission()->associate($permManageMenus);
         $route->save();
     }
     // Associate manage-permission permissions to routes starting with 'admin.permissions.'
     $managePermRoutes = Route::where('name', 'like', "admin.permissions.%")->get()->all();
     foreach ($managePermRoutes as $route) {
         $route->permission()->associate($permManagePermissions);
         $route->save();
     }
     // Associate manage-roles permissions to routes starting with 'admin.roles.'
     $manageRoleRoutes = Route::where('name', 'like', "admin.roles.%")->get()->all();
     foreach ($manageRoleRoutes as $route) {
         $route->permission()->associate($permManageRoles);
         $route->save();
     }
     // Associate manage-routes permissions to routes starting with 'admin.routes.'
     $manageRouteRoutes = Route::where('name', 'like', "admin.routes.%")->get()->all();
     foreach ($manageRouteRoutes as $route) {
         $route->permission()->associate($permManageRoutes);
         $route->save();
     }
     // Associate manage-users permissions to routes starting with 'admin.users.'
     $manageUserRoutes = Route::where('name', 'like', "admin.users.%")->get()->all();
     foreach ($manageUserRoutes as $route) {
         $route->permission()->associate($permManageUsers);
         $route->save();
     }
     // Associate the admin-settings permissions
     $routeAdminSettings = Route::where('name', 'admin.settings.index')->get()->first();
     $routeAdminSettings->permission()->associate($permAdminSettings);
     $routeAdminSettings->save();
     ////////////////////////////////////
     // Create role: admins
     $roleAdmins = Role::create(["name" => "admins", "display_name" => "Administrators", "description" => "Administrators have no restrictions", "enabled" => true]);
     // Create role: users
     // Assign permission basic-authenticated
     $roleUsers = Role::create(["name" => "users", "display_name" => "Users", "description" => "All authenticated users", "enabled" => true]);
//.........这里部分代码省略.........
开发者ID:bztrn,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:101,代码来源:ProductionSeeder.php

示例9: store

 public function store(Request $request)
 {
     $info = $request->only('info');
     Menu::create($info['info']);
     return view('message', ['msg' => '操作成功', 'redirect' => route('menus.index')]);
 }
开发者ID:ruolinn,项目名称:lcms,代码行数:6,代码来源:MenusController.php

示例10: storeSettings

 /**
  * Update/Store admin menu settings
  * POST /admin/settings
  *
  * @return Response
  */
 public function storeSettings()
 {
     $data = Input::all();
     Log::info($data);
     $allMenus = Menu::lists('name', 'id');
     $allItems = MenuItem::lists('title', 'id');
     //existing menus
     foreach ($data['menus'] as $i => $menu) {
         $m = Menu::updateOrCreate(['id' => $i], array('name' => $menu, 'link' => $data['mlinks'][$i], 'sort_id' => $data['msorts'][$i]));
         if (isset($data['imenus'][$i])) {
             foreach ($data['imenus'][$i] as $k => $im) {
                 $sm = MenuItem::updateOrCreate(['id' => $k], array('title' => $im, 'link' => $data['ilinks'][$i][$k], 'sort_id' => $data['isorts'][$i][$k]));
                 unset($allItems[$k]);
             }
         }
         if (isset($data['submenus'][$i])) {
             foreach ($data['submenus'][$i] as $k => $sb) {
                 MenuItem::create(array('menu_id' => $i, 'title' => $sb, 'link' => $data['sublinks'][$i][$k], 'sort_id' => $data['subsorts'][$i][$k]));
             }
         }
         unset($allMenus[$i]);
     }
     //new menus
     if (isset($data['newmenus'])) {
         foreach ($data['newmenus'] as $i => $nmenu) {
             $m = Menu::create(array('name' => $nmenu, 'link' => $data['newlinks'][$i], 'sort_id' => $data['newsorts'][$i]));
             if (isset($data['submenus'][$i])) {
                 foreach ($data['submenus'][$i] as $k => $im) {
                     $sm = MenuItem::create(array('menu_id' => $m->id, 'title' => $im, 'link' => $data['sublinks'][$i][$k], 'sort_id' => $data['subsorts'][$i][$k]));
                 }
                 unset($data['submenus'][$i]);
                 unset($allItems[$i]);
             }
         }
         //new submenus of exising menus
         foreach ($data['submenus'] as $k => $im) {
             foreach ($data['submenus'][$k] as $i => $sb) {
                 MenuItem::create(array('menu_id' => $k, 'title' => $sb, 'link' => $data['sublinks'][$k][$i], 'sort_id' => $data['subsorts'][$k][$i]));
             }
         }
     }
     foreach ($allItems as $i => $title) {
         MenuItem::where('id', '=', $i)->delete();
     }
     foreach ($allMenus as $m => $name) {
         Menu::where('id', '=', $m)->delete();
     }
     if (Request::ajax()) {
         return Response::json('success');
     }
     return View::make('admin.settings');
 }
开发者ID:remix101,项目名称:compex,代码行数:58,代码来源:AdminController.php


注:本文中的app\models\Menu::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。