A free open source IT asset/license management system
Fixes status label inline creation
snipee4275bd3d324
diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.phpindex 0387c3a805..aabb5e74f2 100755--- a/app/Http/Controllers/StatuslabelsController.php+++ b/app/Http/Controllers/StatuslabelsController.php@@ -119,33 +119,24 @@ class StatuslabelsController extends Controllerpublic function store(){- // create a new model instance+ // create a new status label instance$statuslabel = new Statuslabel();- $statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('modal-statuslabel_types'));-- // attempt validation- if ($statuslabel->validate($new)) {-- // Save the Statuslabel data- $statuslabel->name = e(Input::get('name'));- $statuslabel->user_id = Auth::user()->id;- $statuslabel->notes = '';- $statuslabel->deployable = $statustype['deployable'];- $statuslabel->pending = $statustype['pending'];- $statuslabel->archived = $statustype['archived'];-- // Was the asset created?- if ($statuslabel->save()) {- // Redirect to the new Statuslabel page- return JsonResponse::create($statuslabel);- } else {- return JsonResponse::create(["error" => "Couldn't save Statuslabel"], 500);- }- } else {- // failure- $errors = $statuslabel->getErrors();- return JsonResponse::create(["error" => "Failed validation: ".print_r($errors->all('<li>:message</li>'), true)], 500);+ $statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));+ $statuslabel->name = e(Input::get('name'));+ $statuslabel->user_id = Auth::user()->id;+ $statuslabel->notes = '';+ $statuslabel->deployable = $statustype['deployable'];+ $statuslabel->pending = $statustype['pending'];+ $statuslabel->archived = $statustype['archived'];+++ if ($statuslabel->isValid()) {+ $statuslabel->save();+ // Redirect to the new Statuslabel page+ return JsonResponse::create($statuslabel);}+ return JsonResponse::create(["error" => "Failed validation: ".print_r($statuslabel->getErrors()->first(), true)], 500);+}diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.phpindex 1537a86728..9861799c58 100755--- a/app/Models/Statuslabel.php+++ b/app/Models/Statuslabel.php@@ -75,11 +75,11 @@ class Statuslabel extends Model$statustype['deployable'] = 0;$statustype['archived'] = 1;- } elseif ($type == 'undeployable') {+ } else {$statustype['pending'] = 0;$statustype['deployable'] = 0;$statustype['archived'] = 0;- }+ }return $statustype;}