Example #1
0
 public function page_by_id($id)
 {
     $post = Post::find($id);
     if ($post) {
         return $post;
     }
     return false;
 }
Example #2
0
 public function backend_menu_tree($items, $parent_id = 0)
 {
     $childs = $this->get_node_childs($items, $parent_id);
     $output = "";
     if (!empty($childs)) {
         $output .= "<ol class='dd-list'>";
         foreach ($childs as $b) {
             $the_url = $b['url'];
             if (!$the_url) {
                 $post = \Post\Post::find($b['post_id']);
                 $the_url = $post ? url($post->permalink) : "";
             }
             $output .= "<li class='dd-item' data-id='" . $b['id'] . "'>" . "<a target='_parent' class='btn btn-danger btn-xs delete_toggle' rel='" . $b['id'] . "' href='#'><i class='fa fa-trash-o'></i></a>\n\t\t\t\t            <a target='_parent' class='btn btn-primary btn-xs edit_toggle' rel='" . $b['id'] . "'><i class='fa fa-edit'></i></a>" . "<div class='dd-handle' data-url='" . $the_url . "'>" . $b['title'] . "</div>";
             $output .= $this->backend_menu_tree($items, $b['id']);
             $output .= '</li>';
         }
         $output .= "</ol>";
     }
     return $output;
 }
Example #3
0
 public function postAddItem($menu_id)
 {
     if (!is_null($this->request->get('page-id'))) {
         $page_id = $this->request->get('page-id');
         $max = MainMenu::max('weight');
         $post = Post::find($page_id);
         MainMenu::insert(['title' => $post->subject, 'parent_id' => '0', 'url' => '', 'post_id' => $post->id, 'menu_id' => $menu_id, 'weight' => $max + 1]);
         return $this->redirector->route('menu.update', [$menu_id]);
     }
     $max = MainMenu::max('weight');
     MainMenu::insert(['title' => "عنوان", 'parent_id' => '0', 'url' => '', 'menu_id' => $menu_id, 'weight' => $max + 1]);
     return $this->redirector->route('menu.update', [$menu_id]);
 }