/** * 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; }
/** * 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); }
/** * Get post info by its id * * @param $id * @return mixed */ public function getPostById($id) { $post = $this->post->findById($id); if (!$post) { throw new \Exception('Your provided post id does not return data.'); } return $post; }