Fixes T372: Comment counters are now updated when new comments are made.

This commit is contained in:
Peter Deltchev 2015-09-12 21:16:03 -07:00
parent 205e034174
commit 01ebdf5ac0

View file

@ -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));
}
}
}