diff --git a/app/Caches/ModerationStat.php b/app/Caches/ModerationStat.php index 518b76f3..db625365 100644 --- a/app/Caches/ModerationStat.php +++ b/app/Caches/ModerationStat.php @@ -24,10 +24,14 @@ class ModerationStat extends Cache $statRepo = new StatRepo(); $articleCount = $statRepo->countPendingArticles(); + $questionCount = $statRepo->countPendingQuestions(); + $answerCount = $statRepo->countPendingAnswers(); $commentCount = $statRepo->countPendingComments(); return [ 'article_count' => $articleCount, + 'question_count' => $questionCount, + 'answer_count' => $answerCount, 'comment_count' => $commentCount, ]; } diff --git a/app/Http/Admin/Services/Article.php b/app/Http/Admin/Services/Article.php index 3ccb3aef..c8b96086 100644 --- a/app/Http/Admin/Services/Article.php +++ b/app/Http/Admin/Services/Article.php @@ -127,14 +127,12 @@ class Article extends Service $validator = new ArticleValidator(); - $category = $validator->checkCategory($post['category_id']); $title = $validator->checkTitle($post['title']); $article = new ArticleModel(); $article->published = ArticleModel::PUBLISH_APPROVED; $article->owner_id = $user->id; - $article->category_id = $category->id; $article->title = $title; $article->create(); diff --git a/app/Http/Admin/Services/Index.php b/app/Http/Admin/Services/Index.php index bb529fb8..4749042a 100644 --- a/app/Http/Admin/Services/Index.php +++ b/app/Http/Admin/Services/Index.php @@ -2,11 +2,11 @@ namespace App\Http\Admin\Services; -use App\Caches\ModerationStat; use App\Caches\SiteGlobalStat; use App\Caches\SiteTodayStat; use App\Library\AppInfo; use App\Library\Utils\ServerInfo; +use App\Repos\Stat as StatRepo; use GuzzleHttp\Client; class Index extends Service @@ -56,9 +56,19 @@ class Index extends Service public function getModerationStat() { - $cache = new ModerationStat(); + $statRepo = new StatRepo(); - return $cache->get(); + $articleCount = $statRepo->countPendingArticles(); + $questionCount = $statRepo->countPendingQuestions(); + $answerCount = $statRepo->countPendingAnswers(); + $commentCount = $statRepo->countPendingComments(); + + return [ + 'article_count' => $articleCount, + 'question_count' => $questionCount, + 'answer_count' => $answerCount, + 'comment_count' => $commentCount, + ]; } public function getReleases() diff --git a/app/Http/Admin/Views/index/main_mod_stat.volt b/app/Http/Admin/Views/index/main_mod_stat.volt index 60c96ce2..f9c5a1ba 100644 --- a/app/Http/Admin/Views/index/main_mod_stat.volt +++ b/app/Http/Admin/Views/index/main_mod_stat.volt @@ -14,7 +14,7 @@