diff --git a/app/Commands/EditTrackCommand.php b/app/Commands/EditTrackCommand.php index 900c94d5..a52c400e 100644 --- a/app/Commands/EditTrackCommand.php +++ b/app/Commands/EditTrackCommand.php @@ -71,7 +71,8 @@ class EditTrackCommand extends CommandBase 'track_type_id' => 'required|exists:track_types,id|not_in:'.TrackType::UNCLASSIFIED_TRACK, 'songs' => 'required_when:track_type,2|exists:songs,id', 'cover_id' => 'exists:images,id', - 'album_id' => 'exists:albums,id' + 'album_id' => 'exists:albums,id', + 'username' => 'exists:users,username' ]; if (isset($this->_input['track_type_id']) && $this->_input['track_type_id'] == 2) { @@ -148,10 +149,12 @@ class EditTrackCommand extends CommandBase $oldid = null; - if (isset($this->_input['user_id'])) { - if ($track->user_id != $this->_input['user_id']) { + if (isset($this->_input['username'])) { + $newid = User::where('username', $this->_input['username'])->first()->id; + + if ($track->user_id != $newid) { $oldid = $track->user_id; - $track->user_id = $this->_input['user_id']; + $track->user_id = $newid; } } diff --git a/app/Models/Track.php b/app/Models/Track.php index 9d05cb9e..1944989a 100644 --- a/app/Models/Track.php +++ b/app/Models/Track.php @@ -448,6 +448,7 @@ class Track extends Model implements Searchable $returnValue['description'] = $track->description; $returnValue['is_downloadable'] = !$track->isPublished() ? true : (bool) $track->is_downloadable; $returnValue['license_id'] = $track->license_id != null ? $track->license_id : 3; + $returnValue['username'] = User::whereId($track->user_id)->first()->username; return $returnValue; } diff --git a/public/templates/directives/track-editor.html b/public/templates/directives/track-editor.html index eae3f1bb..cafb5732 100644 --- a/public/templates/directives/track-editor.html +++ b/public/templates/directives/track-editor.html @@ -108,10 +108,10 @@