public function index() { // This is a temporary fix for how we'll build our main menu. At some point I'd like to make this a gui. $menu = [['id' => 1, 'name' => 'Register', 'slug' => 'register', 'url' => '/register', 'description' => 'Website Registration', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'guest'], ['id' => 2, 'name' => 'Login', 'slug' => 'login', 'url' => '/login', 'description' => 'Login to Your Account', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'guest'], ['id' => 3, 'name' => 'Account', 'slug' => 'account', 'url' => '/profile', 'description' => 'View Your Profile', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'users', 'children' => [['id' => 4, 'name' => 'Logout', 'slug' => 'logout', 'url' => '/logout', 'description' => 'Website Logout', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'users'], ['id' => 5, 'name' => 'Users', 'slug' => 'users', 'url' => '/users', 'description' => 'Admin: Users', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'admin'], ['id' => 6, 'name' => 'Groups', 'slug' => 'groups', 'url' => '/groups', 'description' => 'Admin: Groups', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'admin', 'children' => [['id' => 7, 'name' => 'test', 'slug' => 'test', 'url' => '/test', 'description' => 'test', 'icon' => '', 'cssClass' => '', 'cssId' => '', 'onClick' => '', 'userGroup' => 'users']]]]]]; MainMenu::buildTree($menu); //return "<pre>" . json_encode(MainMenu::all()->toHierarchy(), JSON_PRETTY_PRINT) . "</pre>"; return MainMenu::all()->toHierarchy(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $menu = MainMenu::orderBy('urutan', 'ASC')->get(); $data = "Coba test data"; //$this->menus = $menu return view('site.index', ['menu' => $menu]); //return View::make('site.index'); }
/** * @param View $view * * This is the method that outputs the mainMenu for our website. * Menu will be output as a nested set array. * */ public function compose(View $view) { // First we have to determine if the user is a guest or a logged in user. if (Sentry::check()) { $this->guest = false; $user = Sentry::getUser(); } else { $user = ''; $this->guest = true; } // Next we get the menu contents and start rendering the menu. $menu = MainMenu::all()->toHierarchy(); $html = "<ul class='nav navbar-nav'>"; foreach ($menu as $node) { $html .= $this->checkNode($node, $user); } $html .= "</ul>"; $view->with('MainMenu', $html); }