Ejemplo n.º 1
0
 /**
  * Remove the specified Links from storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $links = $this->linksRepository->findLinksById($id);
     $menu = $links->menu_id;
     if (empty($links)) {
         Quarx::notification('Link not found', 'warning');
         return redirect(route('quarx.links.index'));
     }
     $links->delete();
     Quarx::notification('Link deleted successfully.', 'success');
     return redirect(URL::to('quarx/menus/' . $menu . '/edit'));
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }