Exemplo n.º 1
0
 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     // Load all menus ordered by Parent (asc), Position (asc), Label (asc) and finally ID (asc).
     $menus = Menu::orderBy('parent_id', 'ASC')->orderBy('position', 'ASC')->orderBy('label', 'ASC')->orderBy('id', 'ASC')->get();
     // Convert menu query result to JSON for JSTree
     $menusJson = $this->menusOrmToJsTreeJson($menus);
     // List label and id of all menus ordered by Label (asc).
     $parents = Menu::orderBy('label', 'ASC')->orderBy('id', 'ASC')->get();
     // Convert to array.
     $parents = $parents->toArray();
     // Return view
     return view('menu-builder::admin-menus', compact('menus', 'menusJson', 'parents'));
 }