/** * Deletes all posts for a specific topic * * @param Topic $topic * * @return mixed */ public function deletePostsForTopic(Topic $topic) { $baseQuery = $this->postModel->where('topic_id', '=', $topic->id); $posts = $baseQuery->get(); foreach ($posts as $post) { $this->likesRepository->removeLikesForContent($post); } return $baseQuery->forceDelete(); }
private function recountUsers() { $this->info('Recounting user counters...'); $users = User::all(); foreach ($users as $user) { $user->num_posts = Post::where('user_id', '=', $user->id)->count(); $user->num_topics = Topic::where('user_id', '=', $user->id)->count(); $user->save(); } $this->info('Done' . PHP_EOL); }
/** * @return \Illuminate\View\View */ public function queue() { $topics = Topic::where('approved', 0)->get(); $posts = Post::where('approved', 0)->get(); return view('moderation.queue', ['queued_topics' => $topics, 'queued_posts' => $posts])->withActive('queue'); }