示例#1
0
 /**
  * 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();
 }
示例#2
0
 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);
 }
示例#3
0
 /**
  * @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');
 }