#86: Fixed editing albums with more than 1 track

This commit is contained in:
Josef Citrine 2016-07-11 21:07:45 +01:00
parent 45dae68497
commit a57c1640e8

View file

@ -63,7 +63,6 @@ class EditAlbumCommand extends CommandBase
'title' => 'required|min:3|max:50', 'title' => 'required|min:3|max:50',
'cover' => 'image|mimes:png|min_width:350|min_height:350', 'cover' => 'image|mimes:png|min_width:350|min_height:350',
'cover_id' => 'exists:images,id', 'cover_id' => 'exists:images,id',
'track_ids' => 'exists:tracks,id',
'username' => 'exists:users,username' 'username' => 'exists:users,username'
]; ];
@ -73,6 +72,14 @@ class EditAlbumCommand extends CommandBase
return CommandResponse::fail($validator); return CommandResponse::fail($validator);
} }
$trackIds = explode(',', $this->_input['track_ids']);
$trackIdsCount = count($trackIds);
$trackDbCount = DB::table('tracks')->whereIn('id', $trackIds)->count();
if ($trackDbCount != $trackIdsCount) {
return CommandResponse::fail("Track IDs invalid");
}
$this->_album->title = $this->_input['title']; $this->_album->title = $this->_input['title'];
$this->_album->description = $this->_input['description']; $this->_album->description = $this->_input['description'];