/** * @Access("blog: manage comments") * @Request({"filter": "array", "post":"int", "page":"int"}) */ public function commentAction($filter = [], $post = 0, $page = null) { $post = Post::find($post); $filter['order'] = 'created DESC'; return ['$view' => ['title' => $post ? __('Comments on %title%', ['%title%' => $post->title]) : __('Comments'), 'name' => 'blog/admin/comment-index.php'], '$data' => ['statuses' => Comment::getStatuses(), 'config' => ['filter' => (object) $filter, 'page' => $page, 'post' => $post, 'limit' => App::module('blog')->config('comments.comments_per_page')]]]; }
/** * @Access("blog: manage comments") * @Route("/{id}", methods="DELETE", requirements={"id"="\d+"}) * @Request({"id": "int"}, csrf=true) */ public function deleteAction($id) { if ($comment = Comment::find($id)) { $comment->delete(); } return ['message' => 'success']; }
/** * Updates the comments info on post. * * @param int $id */ public static function updateCommentInfo($id) { $query = Comment::where(['post_id' => $id, 'status' => Comment::STATUS_APPROVED]); self::where(compact('id'))->update(['comment_count' => $query->count()]); }