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 +}