/** * Get all threads created by a user. * * @param int $userId The ID of the user. * * @return mixed */ public function allForUser($userId = 0) { $unviewableForums = $this->permissionChecker->getUnviewableIdsForContent('forum'); return $this->topicModel->where('user_id', '=', $userId)->whereNotIn('forum_id', $unviewableForums)->get(); }
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'); }