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


PHP Menu::lists方法代码示例

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


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

示例1: __construct

 public function __construct(Menu $menu)
 {
     $this->paginationlimit = 5;
     $this->menuItems = ['' => 'Select Options'] + $menu->lists('name', 'id');
 }
开发者ID:udayc,项目名称:travel,代码行数:5,代码来源:PageController.php

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