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


PHP Menu::find方法代码示例

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


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

示例1: update

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

示例2: run

 public function run()
 {
     $menu = Menu::find()->where(['position' => 'bottom'])->one();
     $p = explode(',', $menu->content);
     $model = Page::find()->where(['id' => $p])->all();
     return $this->render('links', ['pages' => $model]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:7,代码来源:Links.php

示例3: getChildMenu

 public static function getChildMenu($ParentId, $ParentLabel)
 {
     $menuData = Menu::find()->where(['ismenu' => TRUE, 'status' => TRUE, 'parentid' => $ParentId, 'isweb' => FALSE])->orderBy('orderby')->all();
     $submenu = array();
     $menu = array();
     if (!empty($menuData)) {
         foreach ($menuData as $mKey => $mValue) {
             $menu['label'] = Html::tag('i', '', ['class' => $mValue['labelicon']]) . Html::encode($mValue['label']);
             $urlArray = [$mValue['module'], $mValue['controller'], $mValue['action']];
             $menu['url'] = \Yii::$app->urlManager->createUrl(implode('/', $urlArray));
             $class = '';
             if (\Yii::$app->controller->id == $urlArray[1] && \Yii::$app->controller->action->id == $urlArray[2]) {
                 $class = 'active';
                 \Yii::$app->params['breadcrumbs'][] = $ParentLabel;
                 \Yii::$app->params['breadcrumbs'][] = $mValue['label'];
             }
             $menu['options'] = ['class' => $class];
             $submenu[$mValue['orderby']] = $menu;
             unset($menu, $urlArray);
         }
         // $submenu['options'] = ['class' => 'children'];
     }
     return $submenu;
     //, 'options' => ['class' => 'children']];
 }
开发者ID:kurmidev,项目名称:ims,代码行数:25,代码来源:MenuHelper.php

示例4: destroy

 public function destroy($id)
 {
     //
     $data = Menu::find($id);
     if ($data->delete()) {
         return response()->json(array('success' => TRUE, 'msg' => 'Data Berhasil Dihapus'));
     }
 }
开发者ID:brutalcrozt,项目名称:SI-Sekolah-L5,代码行数:8,代码来源:MenuController.php

示例5: postDestroy

 public function postDestroy()
 {
     $menu = Menu::find(Input::get('id'));
     if ($menu) {
         $menu->delete();
         return Redirect::back()->with('message', 'Элемент меню удален');
     }
     return Redirect::back()->with('message', "Ошибка");
 }
开发者ID:venomir,项目名称:tc,代码行数:9,代码来源:MenuController.php

示例6: actionPage

 public function actionPage($slug)
 {
     $page = Page::find()->where(['slug' => $slug])->one();
     if ($slug == 'home') {
         return $this->goHome();
     }
     if (Yii::$app->deviceDetect->isMobile()) {
         $this->layout = "//mobile";
         $mobile = 'mobile/';
     } else {
         $this->layout = "//inner";
         $mobile = '';
     }
     if ($page->parent_id == 0) {
         $menu = Menu::find()->where(['position' => 'bottom'])->one();
         $links = explode(',', $menu->content);
         if ($page->id == 13) {
             $group_news = Post::find()->where(['page_id' => 14])->orderBy(['create_date' => SORT_DESC])->all();
             $industry_news = Post::find()->where(['page_id' => 15])->orderBy(['create_date' => SORT_DESC])->limit(6)->all();
             $media_news = Post::find()->where(['page_id' => 16])->orderBy(['create_date' => SORT_DESC])->limit(6)->all();
             $pic_news = Photo::find()->where(['page_id' => 39, 'parent_id' => 0])->orderBy(['create_date' => SORT_DESC])->limit(10)->all();
             $headlines = Post::find()->where(['is_headline' => 1])->orderBy(['create_date' => SORT_DESC])->all();
             return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'group_news' => $group_news, 'industry_news' => $industry_news, 'media_news' => $media_news, 'pic_news' => $pic_news, 'headlines' => $headlines]);
         } else {
             if (in_array($page->id, $links)) {
                 return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'menu' => Page::find()->where(['id' => $links])->all()]);
             }
         }
         $menu = Page::find()->where(['parent_id' => $page->id])->orderBy(['display_order' => SORT_ASC])->all();
         $s = $menu ? $menu[0]->slug : null;
         return $this->redirect(['page', 'slug' => $s]);
     } else {
         $menu = Page::find()->where(['parent_id' => $page->parent_id])->orderBy(['display_order' => SORT_ASC])->all();
     }
     if ($page->type == 3) {
         //新闻列表
         $query = Post::find()->where(['page_id' => $page->id]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 12, 'totalCount' => $countQuery->count()]);
         $posts = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
         return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'menu' => $menu, 'pnation' => $pnation, 'posts' => $posts]);
     } else {
         if ($page->type == 4) {
             //相册列表
             $query = Photo::find()->where(['page_id' => $page->id, 'parent_id' => 0]);
             $countQuery = clone $query;
             $pnation = new Pagination(['defaultPageSize' => 9, 'totalCount' => $countQuery->count()]);
             $albums = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
             //            $albums = Photo::find()->where(['page_id'=>$page->id,'parent_id'=>0])->orderBy(['create_date'=>SORT_DESC])->all();
             return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'albums' => $albums, 'pnation' => $pnation, 'menu' => $menu]);
         }
     }
     return $this->render($mobile . 'template/' . $page->template, ['page' => $page, 'menu' => $menu]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:54,代码来源:SiteController.php

示例7: getAllChild

function getAllChild($role_id, $parent_id = NULL, $level = 0)
{
    foreach (\app\models\Menu::find()->where(["parent_id" => $parent_id])->all() as $menu) {
        ?>
                    <div class="form-group" style="padding-left: <?php 
        echo $level * 20;
        ?>
px">
                        <label>
                            <input type="checkbox" name="menu[]" value="<?php 
        echo $menu->id;
        ?>
" class="minimal" <?php 
        echo isChecked($role_id, $menu->id) ? "checked" : "";
        ?>
>
                        </label>
                        <label style="padding-left: 10px"> <?php 
        echo $menu->name;
        ?>
</label>
                    </div>
                <?php 
        //Show All Actions
        $camelName = Inflector::id2camel($menu->controller);
        $fullControllerName = "app\\controllers\\" . $camelName . "Controller";
        if (class_exists($fullControllerName)) {
            $reflection = new ReflectionClass($fullControllerName);
            $methods = $reflection->getMethods();
            echo "<div class=\"form-group\" style=\"padding-left: " . ($level * 20 + 10) . "px;\">";
            echo "<label><input type=\"checkbox\" class=\"minimal select-all\" ></label><label style=\"padding: 0px 20px 0px 5px\"> Select All</label>";
            foreach ($methods as $method) {
                if (substr($method->name, 0, 6) == "action" && $method->name != "actions") {
                    $camelAction = substr($method->name, 6);
                    $id = Inflector::camel2id($camelAction);
                    $name = Inflector::camel2words($camelAction);
                    $action = \app\models\Action::find()->where(["action_id" => $id, "controller_id" => $menu->controller])->one();
                    if ($action == NULL) {
                        //If the action not in database, save it !
                        $action = new \app\models\Action();
                        $action->action_id = $id;
                        $action->controller_id = $menu->controller;
                        $action->name = $name;
                        $action->save();
                    }
                    showCheckbox("action[]", $action->id, $name, hasAccessToAction($role_id, $action->id));
                }
            }
            echo "</div>";
        }
        getAllChild($role_id, $menu->id, $level + 1);
    }
}
开发者ID:febfeb,项目名称:yii2-basic-ready,代码行数:53,代码来源:detail.php

示例8: update

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

示例9: getMenu

 public static function getMenu($roleId, $parentId = NULL)
 {
     $output = [];
     foreach (Menu::find()->where(["parent_id" => $parentId])->all() as $menu) {
         $obj = ["label" => $menu->name, "icon" => $menu->icon, "url" => SidebarMenu::getUrl($menu), "visible" => SidebarMenu::roleHasAccess($roleId, $menu->id)];
         if (count($menu->menus) != 0) {
             $obj["items"] = SidebarMenu::getMenu($roleId, $menu->id);
         }
         $output[] = $obj;
     }
     return $output;
 }
开发者ID:febfeb,项目名称:yii2-basic-ready,代码行数:12,代码来源:SidebarMenu.php

示例10: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['menu_id' => $this->menu_id, 'parent_id' => $this->parent_id, 'flag_active' => $this->flag_active]);
     $query->andFilterWhere(['like', 'menu_name', $this->menu_name])->andFilterWhere(['like', 'menu_url', $this->menu_url])->andFilterWhere(['like', 'menu_class', $this->menu_class]);
     return $dataProvider;
 }
开发者ID:vab777,项目名称:marts.id_be,代码行数:21,代码来源:MenuSearch.php

示例11: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'is_active' => $this->is_active, 'order' => $this->order, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'user_role', $this->user_role])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'route', $this->route])->andFilterWhere(['like', 'params', $this->params])->andFilterWhere(['like', 'menu_icon_class', $this->menu_icon_class]);
     return $dataProvider;
 }
开发者ID:altairsoft,项目名称:plutos,代码行数:21,代码来源:MenuSearch.php

示例12: search

 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'order' => $this->order, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'controller', $this->controller])->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'icon', $this->icon]);
     return $dataProvider;
 }
开发者ID:febfeb,项目名称:yii2-basic-ready,代码行数:21,代码来源:MenuSearch.php

示例13: run

 public function run()
 {
     $menu = Menu::find()->where(['position' => 'top'])->one();
     $p = explode(",", $menu->content);
     $pages = Page::find()->where(['id' => $p])->all();
     if (strpos(\Yii::$app->request->url, "view-post")) {
         $post = Post::findOne(\Yii::$app->request->get('id'));
         $current_page = $post->page;
     } else {
         $slug = \Yii::$app->request->get('slug');
         $current_page = Page::find()->where(['slug' => $slug])->one();
     }
     return $this->render('nav', ['pages' => $pages, 'current_page' => $current_page]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:14,代码来源:Nav.php

示例14: run

 public function run()
 {
     $menu = Menu::find()->where(['position' => 'top'])->one();
     $p = explode(',', $menu->content);
     $model = Page::find()->orderBy('display_order asc')->all();
     $pages = $this->tree($model, 0, $p);
     if (strpos(\Yii::$app->request->url, "view-post")) {
         $post = Post::findOne(\Yii::$app->request->get('id'));
         $current_page = $post->page;
     } else {
         $slug = \Yii::$app->request->get('slug');
         $current_page = Page::find()->where(['slug' => $slug])->one();
     }
     return $this->render('cateWidget', ['pages' => $pages, 'current_page' => $current_page]);
 }
开发者ID:sanmaowang,项目名称:ycjl,代码行数:15,代码来源:Menus.php

示例15: _moveMenuItem

 private function _moveMenuItem($menu_id, $operator)
 {
     $menu = Menu::find($menu_id);
     $order = $operator == '>' ? 'asc' : 'desc';
     $neighbour = Menu::where('sort', $operator, $menu->sort)->orderBy('sort', $order)->first();
     if (empty($neighbour)) {
         return false;
     }
     $old_sort = $menu->sort;
     $menu->sort = $neighbour->sort;
     $neighbour->sort = $old_sort;
     $menu->save();
     $neighbour->save();
     return true;
 }
开发者ID:garf,项目名称:0ez,代码行数:15,代码来源:MenuController.php


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