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