Esempio n. 1
0
 private function recountTopics()
 {
     $this->info('Recounting topic counters...');
     $topics = Topic::all();
     foreach ($topics as $topic) {
         $posts = Post::where('topic_id', '=', $topic->id)->orderBy('created_at', 'desc');
         $topic->num_posts = $posts->count();
         // We could also update the first_post_id easily with the above query
         // but if that column is wrong everything is wrong
         $topic->last_post_id = $posts->first()->id;
         $topic->save();
     }
     $this->info('Done' . PHP_EOL);
 }
Esempio n. 2
0
 /**
  * Get all threads.
  *
  * @return mixed
  */
 public function all()
 {
     return $this->topicModel->all();
 }