コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $chicken = new MenuItem();
     $chicken->name = "Chicken";
     $chicken->menu_id = 1;
     $chicken->save();
     $fish = new MenuItem();
     $fish->name = "Fish";
     $fish->menu_id = 1;
     $fish->save();
     $salad = new MenuItem();
     $salad->name = "Salad";
     $salad->menu_id = 1;
     $salad->save();
 }
コード例 #2
0
 public function menu_update(Request $request)
 {
     $mnuDAta = $request->all();
     $position = 1;
     $parent = '';
     foreach ($mnuDAta['menu-item-db-id'] as $key => $mnu) {
         $data = [];
         $data['title_sw'] = $mnuDAta['menu-item-title_sw'][$mnuDAta['menu-item-db-id'][$key]];
         $data['title_en'] = $mnuDAta['menu-item-title_en'][$mnuDAta['menu-item-db-id'][$key]];
         $data['url'] = $mnuDAta['menu-item-url'][$mnuDAta['menu-item-db-id'][$key]];
         $data['parent'] = $mnuDAta['menu-item-parent-id'][$key];
         if ($parent != $data['parent']) {
             $parent = $data['parent'];
             $position = 1;
         } else {
             $position++;
         }
         $data['position'] = $position;
         MenuItem::where('id', $mnuDAta['menu-item-db-id'][$key])->update($data);
     }
     return Redirect('menuitems');
 }
コード例 #3
0
ファイル: Item.php プロジェクト: verget/catering
 public function getMenuItems()
 {
     return $this->hasMany(MenuItem::className(), ['item_id' => 'item_id']);
 }
コード例 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $eventId, $menuItemId)
 {
     $menuItem = MenuItem::where('id', '=', $menuItemId)->first();
     if (!$menuItem) {
         return $this->respondNotFound('Menu Item Not Found');
     }
     $itemName = $menuItem->name;
     GuestMenuItem::where('menu_item_id', '=', $menuItemId)->delete();
     $menuItem->delete();
     return $this->respondDeleteSuccess($itemName . ' deleted');
 }
コード例 #5
0
ファイル: MenuController.php プロジェクト: verget/catering
 public function actionDeleteItem()
 {
     $request = Yii::$app->request;
     $item_id = $request->post('item');
     $menu_id = $request->post('menu');
     $item = MenuItem::findOne(['item_id' => $item_id, 'menu_id' => $menu_id]);
     $item->delete();
     return true;
 }
コード例 #6
0
 public function run()
 {
     DB::table('menu_items')->truncate();
     MenuItem::create(['menu_id' => 1, 'title' => 'Support', 'link' => url('support')]);
     MenuItem::create(['menu_id' => 1, 'title' => 'Frequently Asked Questions', 'link' => url('faq')]);
 }
コード例 #7
0
ファイル: AdminController.php プロジェクト: remix101/compex
 /**
  * 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');
 }
コード例 #8
0
ファイル: MenuItem.php プロジェクト: danielchikaka/osh
 public static function getMainMenu($name = "main")
 {
     $menu = MenuItem::where('name', '=', $name);
     $mnu = "";
     $title = 'title_' . Session::get('locale');
     if ($menu == null) {
         return "";
     }
     $par_items = MenuItem::where('name', '=', $name)->where('parent', '=', 0)->orderBy('position', 'ASC')->get();
     foreach ($par_items as $par) {
         $child_items = MenuItem::where('parent', '=', $par->id)->get();
         if ($child_items->count() > 0) {
             $mnu .= "<li><a href='#'>" . $par->{$title} . "</a>";
             $mnu .= '<ul  class="dropdown-menu">';
             foreach ($child_items as $child) {
                 $grands = MenuItem::where('parent', '=', $child->id)->get();
                 if ($grands->count()) {
                     $mnu .= "<li><a href='#'>" . $child->{$title} . "</a>";
                     $mnu .= '<ul  class="dropdown-menu">';
                     foreach ($grands as $grand) {
                         $mnu .= '<li>' . "<a href='{$grand->url}'>" . $grand->{$title} . '</a></li>';
                     }
                     $mnu .= '</ul>';
                 } else {
                     $mnu .= "<li><a href= " . url($child->url) . ">" . $child->{$title} . "</a></li>";
                 }
             }
             $mnu .= '</ul>';
         } else {
             $mnu .= "<li><a href=" . url($par->url) . ">" . $par->{$title} . "</a>";
         }
         $mnu .= "</li>";
     }
     return $mnu;
 }