/** * Delete category by id * * @param $id * @return bool */ public function delete($id) { $category = $this->findById($id); $this->post->detachAllFromCategory($category['id']); $this->category->delete($category['id']); return true; }
/** * Get page info by its id * * @param $id * @return mixed * @throws Exception */ public function getPageById($id) { $post = $this->post->findById($id); if (!$post || $post['type'] != 1) { throw new Exception('Your provided post id does not return data.'); } return $post; }
/** * Initialize navbar * * @param string $name */ public function makeNavbar($name = 'navigation') { $this->app['menu']->make($name, function ($menu) { $posts = $this->post->findByMenuPin(); foreach ($posts as $post) { $menu->add($post['title'], $post['slug']); } }); }
/** * Create a new comment * * @param $postId * @param array $data * @return mixed */ public function create($postId, array $data) { $post = $this->post->findById($postId); if (!$post) { return false; } $data['post_id'] = $post['id']; return $this->comment->create($data); }
/** * Find post by slug * * @param $slug * @return mixed */ public function findBySlug($slug) { $post = $this->post->findBySlug($slug); if (!$post) { throw new \Exception('This post cannot be served because it does not exist.'); } return $post; }