Example #1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('website.navigation.navbar', function ($view) {
         $menuItems = MenuItem::where('parent', null)->orderBy('order')->get();
         $view->with('menuItems', $menuItems);
     });
 }
Example #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $menuItem = MenuItem::findOrfail($id);
     if ($menuItem->children->count() > 0) {
         Session::flash('flash_message', 'A menu item with children can\'t be removed.');
         return Redirect::route('menu::list');
     }
     Session::flash('flash_message', 'Menu item has been removed.');
     $menuItem->delete();
     return Redirect::route('menu::list');
 }