diff --git a/app/Commands/EditTrackCommand.php b/app/Commands/EditTrackCommand.php index 5cdd8af2..900c94d5 100644 --- a/app/Commands/EditTrackCommand.php +++ b/app/Commands/EditTrackCommand.php @@ -146,6 +146,15 @@ class EditTrackCommand extends CommandBase } } + $oldid = null; + + if (isset($this->_input['user_id'])) { + if ($track->user_id != $this->_input['user_id']) { + $oldid = $track->user_id; + $track->user_id = $this->_input['user_id']; + } + } + $track->updateTags(); $track->save(); @@ -153,6 +162,12 @@ class EditTrackCommand extends CommandBase 'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = ' . $this->_track->user_id . ')') ]); + if ($oldid != null) { + User::whereId($oldid)->update([ + 'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = ' . $oldid . ')') + ]); + } + return CommandResponse::succeed(['real_cover_url' => $track->getCoverUrl(Image::NORMAL)]); } diff --git a/public/templates/directives/track-editor.html b/public/templates/directives/track-editor.html index 83406389..eae3f1bb 100644 --- a/public/templates/directives/track-editor.html +++ b/public/templates/directives/track-editor.html @@ -107,6 +107,13 @@ +
+
+ + +
{{errors.title}}
+
+