group()->associate(Group::find($_POST['groupId'])); $vote->points += 1; if(!empty($_POST['comment'])){ $vote->comment = $_POST['comment']; } if(!$vote->save()){ http_response_code(500); }else{ http_response_code(201); } } }else{ echo http_response_code(400); }