mirror of
https://github.com/flarum/core.git
synced 2025-07-19 07:41:22 +02:00
Don't save in the model
This commit is contained in:
@@ -766,7 +766,6 @@ class User extends AbstractModel
|
||||
public function refreshCommentsCount()
|
||||
{
|
||||
$this->comments_count = $this->posts()->count();
|
||||
$this->save();
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -779,7 +778,6 @@ class User extends AbstractModel
|
||||
public function refreshDiscussionsCount()
|
||||
{
|
||||
$this->discussions_count = $this->discussions()->count();
|
||||
$this->save();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -66,11 +66,19 @@ class UserMetadataUpdater
|
||||
|
||||
private function updateCommentsCount(Post $post)
|
||||
{
|
||||
optional($post->user)->refreshCommentsCount();
|
||||
$user = $post->user;
|
||||
|
||||
if ($user && $user->exists) {
|
||||
$user->refreshCommentsCount()->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function updateDiscussionsCount(Discussion $discussion)
|
||||
{
|
||||
optional($discussion->startUser)->refreshDiscussionsCount();
|
||||
$user = $discussion->startUser;
|
||||
|
||||
if ($user && $user->exists) {
|
||||
$user->refreshDiscussionsCount()->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user