From 01ebdf5ac02e18ac188d0b7c7c137d5ef13cbf4a Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Sat, 12 Sep 2015 21:16:03 -0700 Subject: [PATCH] Fixes T372: Comment counters are now updated when new comments are made. --- app/Commands/CreateCommentCommand.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Commands/CreateCommentCommand.php b/app/Commands/CreateCommentCommand.php index 83440a87..bd1eb7ec 100644 --- a/app/Commands/CreateCommentCommand.php +++ b/app/Commands/CreateCommentCommand.php @@ -3,6 +3,7 @@ namespace App\Commands; use App\Comment; +use App\Track; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; @@ -73,7 +74,14 @@ class CreateCommentCommand extends CommandBase $comment->$column = $this->_id; $comment->save(); + + // Recount the track's comments, if this is a track comment + if ($this->_type == 'track') { + $track = Track::find($this->_id); + $track->comment_count = Comment::where('track_id', $this->_id)->count(); + $track->save(); + } return CommandResponse::succeed(Comment::mapPublic($comment)); } -} \ No newline at end of file +}