mirror of
https://github.com/flarum/core.git
synced 2025-08-02 14:37:49 +02:00
ApproveContent then refresh user table DiscussionCount and CommentCount (#16)
This commit is contained in:
8
extensions/approval/src/Listener/ApproveContent.php
Normal file → Executable file
8
extensions/approval/src/Listener/ApproveContent.php
Normal file → Executable file
@@ -44,14 +44,22 @@ class ApproveContent
|
|||||||
{
|
{
|
||||||
$post = $event->post;
|
$post = $event->post;
|
||||||
$discussion = $post->discussion;
|
$discussion = $post->discussion;
|
||||||
|
$user = $discussion->user;
|
||||||
|
|
||||||
$discussion->refreshCommentCount();
|
$discussion->refreshCommentCount();
|
||||||
$discussion->refreshLastPost();
|
$discussion->refreshLastPost();
|
||||||
|
|
||||||
if ($post->number == 1) {
|
if ($post->number == 1) {
|
||||||
$discussion->is_approved = true;
|
$discussion->is_approved = true;
|
||||||
|
|
||||||
|
$discussion->afterSave(function () use ($user) {
|
||||||
|
$user->refreshDiscussionCount();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$discussion->save();
|
$discussion->save();
|
||||||
|
|
||||||
|
$user->refreshCommentCount();
|
||||||
|
$user->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user