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


PHP MenuItem::where方法代码示例

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


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

示例1: testMovingNodeNotAffectingOtherMenu

 public function testMovingNodeNotAffectingOtherMenu()
 {
     $node = MenuItem::where('menu_id', '=', 1)->first();
     $node->down();
     $node = MenuItem::where('menu_id', '=', 2)->first();
     $this->assertEquals(1, $node->getLft());
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:7,代码来源:ScopedNodeTest.php

示例2: deleteCategoryInfo

 public function deleteCategoryInfo($slug)
 {
     $results = \MenuCategory::where('menu_category_slug', '=', $slug)->get();
     foreach ($results as $result) {
         $id = $result->menu_category_id;
     }
     $items_using_cat = \MenuItem::where('menu_item_category_fk', '=', $id)->get();
     foreach ($items_using_cat as $item_using_cat) {
         if ($item_using_cat) {
             return \Redirect::to("admin/category/edit/{$slug}")->with('message', '<div class="alert alert-dismissible alert-danger alert-link">Unable to delete category. Please make sure no items are using this category.</p></div>');
         }
     }
     //if an item exists that has this cat's fk, reload the page with an error
     if (\Auth::check()) {
         \DB::beginTransaction();
         try {
             $statement = \MenuCategory::find($id);
             $statement->delete();
         } catch (ValidationException $e) {
             DB::rollback();
             throw $e;
         }
         \DB::commit();
         return \Redirect::to('admin')->with('message', '<div class="alert alert-dismissible alert-success alert-link">Category has been deleted</p></div>');
     }
     return \Redirect::to('admin');
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:27,代码来源:DeleteMenuCategory.php

示例3: showSingle

 public function showSingle($slug)
 {
     $slugs = MenuItem::where('menu_item_slug', '=', $slug)->get();
     foreach ($slugs as $slug) {
         $slug = $slug->menu_item_id;
     }
     return View::make('menu-items.single-item')->withSlug($slug);
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:8,代码来源:MenuController.php

示例4: getItemInfo

 public function getItemInfo($slug)
 {
     $results = \MenuItem::where('menu_item_slug', '=', $slug)->get();
     foreach ($results as $result) {
         $id = $result->menu_item_id;
         $menu_item_name = $result->menu_item_name;
     }
     return \View::make('menu-items.delete')->withSlug($slug)->withMenuItemName($menu_item_name);
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:9,代码来源:DeleteMenuItem.php

示例5: nameToSlug

 public function nameToSlug($validated)
 {
     $slug = \Input::get('name');
     $slug = preg_replace('#[ -]+#', '-', $slug);
     $slug = strtolower($slug);
     $results = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_slug', 'menu_item_id'));
     $slug_check = "";
     foreach ($results as $result) {
         $slug_check = $result->menu_item_slug;
     }
     if ($slug_check !== $slug) {
         return true;
     }
     return false;
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:15,代码来源:NewMenuItem.php

示例6: returnAllMenuInfo

 public function returnAllMenuInfo($slug)
 {
     $results = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_description', 'menu_item_picture_uri', 'menu_item_name', 'menu_item_slug', 'menu_item_id', 'menu_item_category_fk', 'menu_item_short', 'menu_item_price'));
     foreach ($results as $result) {
         $menu_item_description = $result->menu_item_description;
         $menu_item_name = $result->menu_item_name;
         $menu_item_picture_uri = $result->menu_item_picture_uri;
         $menu_item_id = $result->menu_item_id;
         $slug = $result->menu_item_slug;
         $menu_item_category_fk = $result->menu_item_category_fk;
         $menu_item_short = $result->menu_item_short;
         $menu_item_price = $result->menu_item_price;
     }
     function getCategories()
     {
         $category = array();
         $categories = \MenuCategory::get();
         foreach ($categories as $cat) {
             $cat_name = $cat->menu_category_name;
             $cat_id = $cat->menu_category_id;
             $category[$cat_id] = $cat_name;
         }
         return $category;
     }
     function getDefault($menu_item_category_fk)
     {
         $results = \MenuCategory::where('menu_category_id', '=', $menu_item_category_fk)->get(array('menu_category_id'));
         foreach ($results as $result) {
             $category = $result->menu_category_id;
         }
         return $category;
     }
     $categories = getCategories();
     $default = "";
     if (isset($menu_item_category_fk)) {
         $default = getDefault($menu_item_category_fk);
     }
     if (\Auth::check()) {
         if (!isset($menu_item_description)) {
             return \Redirect::to('admin');
         }
         return \View::make('menu-items.edit')->withMenuItemDescription($menu_item_description)->withMenuItemPictureUri($menu_item_picture_uri)->withMenuItemName($menu_item_name)->withMenuItemShort($menu_item_short)->withSlug($slug)->withCategories($categories)->withDefault($default)->withMenuItemPrice($menu_item_price);
     }
     return \Redirect::to('admin');
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:45,代码来源:GetMenuItem.php

示例7: checkNameMatch

 public function checkNameMatch($slug)
 {
     $get_name = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_name'));
     foreach ($get_name as $name) {
         $name = $name->menu_item_name;
     }
     //-----------
     $nameprep = \Input::get('name');
     $nameprep = preg_replace('#[ -]+#', '-', $nameprep);
     $nameprep = strtolower($nameprep);
     //------------
     $name_check = \MenuItem::where('menu_item_slug', '=', $nameprep)->get(array('menu_item_name'));
     foreach ($name_check as $get_name) {
         $name_check = $get_name->menu_item_name;
     }
     $result = strcasecmp($name, $name_check);
     if ($result === 0) {
         return true;
     }
     return false;
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:21,代码来源:CheckEditedItem.php

示例8: getallmenus

 public function getallmenus()
 {
     $menuliist = MenuItem::where("menu", Input::get("menu"))->orderBy("label", "asc")->lists("label", "id");
     $menuliist[0] = "Select parent";
     $html = '	<label for="label">MenuItem</label>';
     $html .= Form::select('parent', $menuliist, Input::get("parent"), array("class" => "form-control", "id" => "parentselect"));
     return $html;
 }
开发者ID:tvad911,项目名称:laravel-wordpress-menu-clone,代码行数:8,代码来源:HomeController.php

示例9: updateMenuItem

 public function updateMenuItem($slug)
 {
     $validate = new Validate();
     $validator = $validate->Validate();
     if (\Auth::check()) {
         $check = new CheckEditedItem();
         $slugcheck = $check->checkSlugMatch($slug);
         $namecheck = $check->checkNameMatch($slug);
         $idcheck = $check->checkIdMatch($slug);
         $results = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_description', 'menu_item_picture_uri', 'menu_item_name', 'menu_item_slug', 'menu_item_id', 'menu_item_short', 'menu_item_category_fk', 'menu_item_price'));
         foreach ($results as $result) {
             $menu_item_description = $result->menu_item_description;
             $menu_item_name = $result->menu_item_name;
             $menu_item_picture_uri = $result->menu_item_picture_uri;
             $slug = $result->menu_item_slug;
             $id = $result->menu_item_id;
             $menu_item_short = $result->menu_item_short;
             $menu_item_category_fk = $result->menu_item_category_fk;
             $menu_item_price = $result->menu_item_price;
         }
         if ($validator->fails()) {
             return \Redirect::back()->withErrors($validator);
         }
         if ($idcheck === true) {
             \DB::beginTransaction();
             try {
                 $slug = strtolower($slug);
                 $statement = \MenuItem::find($id);
                 $statement->menu_item_description = \Input::get('description');
                 if (\Input::hasFile('Upload')) {
                     $name = \Input::file('Upload')->getClientOriginalName();
                     \Input::file('Upload')->move('uploads', $name);
                     $statement->menu_item_picture_uri = '/uploads/' . $name;
                 }
                 $statement->menu_item_short = \Input::get('desc');
                 $statement->menu_item_price = \Input::get('price');
                 $statement->menu_item_category_fk = \Input::get('category');
                 $statement->save();
             } catch (ValidationException $e) {
                 DB::rollback();
                 throw $e;
             }
             \DB::commit();
             return \Redirect::to('admin/edit/' . $slug)->with('message', '<div class="alert alert-dismissible alert-success alert-link"><button type="button" class="close" data-dismiss="alert">×</button>Saved at: ' . link_to('/menu/' . $slug) . '</p></div>');
         }
         if ($slugcheck === false || $namecheck === false) {
             $slug = \Input::get('name');
             $slug = preg_replace('#[ -]+#', '-', $slug);
             $slug = strtolower($slug);
             $results = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_id'));
             foreach ($results as $result) {
                 $check_id = $result->menu_item_id;
             }
             if (isset($check_id)) {
                 return \Redirect::back()->withErrors($validator)->withInput(array('name', 'description', 'category', 'desc', 'price'))->with('message', '<p class="alert alert-dismissible alert-danger alert-link">An item with the same name already exists');
             }
             \DB::beginTransaction();
             try {
                 $statement = \MenuItem::find($id);
                 $statement->menu_item_name = \Input::get('name');
                 $statement->menu_item_description = \Input::get('description');
                 if (\Input::hasFile('Upload')) {
                     $name = \Input::file('Upload')->getClientOriginalName();
                     \Input::file('Upload')->move('uploads', $name);
                     $statement->menu_item_picture_uri = '/uploads/' . $name;
                 }
                 $statement->menu_item_slug = $slug;
                 $statement->menu_item_price = \Input::get('price');
                 $statement->menu_item_short = \Input::get('desc');
                 $statement->menu_item_category_fk = \Input::get('category');
                 $statement->save();
             } catch (ValidationException $e) {
                 DB::rollback();
                 throw $e;
             }
             \DB::commit();
             return \Redirect::to('admin/edit/' . $slug)->with('message', '<div class="alert alert-dismissible alert-success alert-link"><button type="button" class="close" data-dismiss="alert">×</button>Saved at: ' . link_to('/menu/' . $slug) . '</p></div>');
         }
         return \Redirect::to('admin/edit/' . $slug)->withErrors($validator)->withInput(array('name', 'description', 'category', 'desc', 'price'))->with('message', '<p class="alert alert-dismissible alert-danger alert-link">An item with the same name already exists');
     }
 }
开发者ID:adamyWA,项目名称:Menu-CMS,代码行数:81,代码来源:UpdateMenuItem.php


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