public static function increasesPostsCount($user, $forum) { return static::aclCheck($user, 'f_postcount', $forum); }
public function refreshForumCache($forum = null, $postsChangeCount = 0) { if ($forum !== null) { if (Forum\Authorize::increasesPostsCount($this, $forum) !== true) { $postsChangeCount = 0; } // In case user_posts is 0 and $postsChangeCount is -1. $newPostsCount = DB::raw("GREATEST(CAST(user_posts AS SIGNED) + {$postsChangeCount}, 0)"); } else { $newPostsCount = $this->forumPosts()->whereIn('forum_id', Forum\Authorize::postsCountedForums($this))->count(); } $lastPost = $this->forumPosts()->last()->select('post_time')->first(); // null time will be stored as 0 by the db. Nothing can be done about // it, short of changing the column to allow null. $lastPostTime = $lastPost !== null ? $lastPost->post_time : null; return $this->update(['user_posts' => $newPostsCount, 'user_lastpost_time' => $lastPostTime]); }