public function saveNavigation(Resource $resource, Node $baseNode = null) { $container = Container::whereName('admin')->first(); $pages = $resource->pages; foreach ($pages as $page) { $node = new Node(); $node->title = $page->title; $node->page()->associate($page); $node->container()->associate($container); $node->save(); if (trim($page->route, '/') == $resource->url) { $root = $node; if ($baseNode) { $root->makeChildOf($baseNode); } } else { $node->makeChildOf($root); } } }
/** * @return Container */ public function getContainer() { return Container::whereName('dashboard')->first(); }