/** * Remove the specified Pages from storage. * * @param int $id * * @return Response */ public function destroy($id) { $pages = $this->pagesRepository->findPagesById($id); if (empty($pages)) { Quarx::notification('Page not found', 'warning'); return redirect(route('quarx.pages.index')); } $pages->delete(); Quarx::notification('Page deleted successfully.', 'success'); return redirect(route('quarx.pages.index')); }
/** * Get a view. * * @param string $slug * @param View $view * * @return string */ public function menu($slug, $view = null) { $pageRepo = new PageRepository(); $menu = MenuRepository::getMenuBySLUG($slug)->first(); if (!$menu) { return ''; } $links = LinkRepository::getLinksByMenuID($menu->id); $response = ''; foreach ($links as $link) { if ($link->external) { $response .= "<a href=\"{$link->external_url}\">{$link->name}</a>"; } else { $page = $pageRepo->findPagesById($link->page_id); $response .= '<a href="' . URL::to('page/' . $page->url) . "\">{$link->name}</a>"; } } if (!is_null($view)) { $response = view($view, ['links' => $links, 'linksAsHtml' => $response]); } if (Gate::allows('quarx', Auth::user())) { $response .= '<a href="' . url('quarx/menus/' . $menu->id . '/edit') . '" style="margin-left: 8px;" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span> Edit</a>'; } return $response; }