/** * Build all Menus. */ public function buildMenus() { $menu = Menu::whereIsRoot()->get(); foreach ($menu as $item) { LavaryMenu::make(Str::slug($item->name), function ($menu) use($item) { $this->buildMenuItems($menu, $item); }); } }
/** * @internal param $generatedRecords */ private function createMenuEntry() { $records = \Modules\Page\Entities\Page::where('published', 1)->take(3)->get(); if ($main = Menu::root()->where(['name' => 'Main'])->first()) { foreach ($records as $element) { $main->children()->create(['name' => $element['title'], 'url' => "page/{$element['slug']}", 'active' => true]); } } }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('menu__menus')->delete(); // Main $main = Menu::create(['name' => 'Main']); $main->children()->create(['name' => 'SocietyCMS', 'url' => '', 'active' => true, 'attribute_class' => 'nav-header']); // Auth $auth = Menu::create(['name' => 'Auth']); $auth->children()->create(['name' => 'Login', 'url' => 'auth/login', 'active' => true]); }
/** * @return array */ public function getMenuItems() { $items = []; $roots = Menu::roots()->visible()->get(); foreach ($roots as $item) { $parent = $this->createItem($item->content->title)->setExtra('patterns', $this->extractPattern($item))->setUri($item->url); $this->attachChildren($item->children, $parent); $items[] = $parent; } return $items; }
/** * */ private function createMenuEntry() { if ($main = Menu::root()->where(['name' => 'Main'])->first()) { $main->children()->create(['name' => 'Gallery', 'url' => 'gallery', 'active' => true]); } }
/** * @return \Illuminate\Support\Collection */ protected function prepareParentItems() { $items = Menu::with('contents')->get()->lists('depth_title', 'id')->toArray(); return [null => trans('menu::menu.root')] + $items; }
/** * @param Request $request * * @return mixed */ public function store(Request $request) { $menu = Menu::create($request->input()); return $this->response()->item($menu, new MenuTransformer()); }
/** * @param Request $request * * @return mixed */ public function destroy(Request $request, $id) { $node = Menu::where('id', $id)->first(); $node->delete(); return $this->response()->noContent(); }