mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Fixes status label inline creation
This commit is contained in:
parent
084db22cd5
commit
e4275bd3d3
|
@ -119,33 +119,24 @@ class StatuslabelsController extends Controller
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
|
|
||||||
// create a new model instance
|
// create a new status label instance
|
||||||
$statuslabel = new Statuslabel();
|
$statuslabel = new Statuslabel();
|
||||||
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('modal-statuslabel_types'));
|
$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'];
|
||||||
|
|
||||||
// attempt validation
|
|
||||||
if ($statuslabel->validate($new)) {
|
|
||||||
|
|
||||||
// Save the Statuslabel data
|
if ($statuslabel->isValid()) {
|
||||||
$statuslabel->name = e(Input::get('name'));
|
$statuslabel->save();
|
||||||
$statuslabel->user_id = Auth::user()->id;
|
// Redirect to the new Statuslabel page
|
||||||
$statuslabel->notes = '';
|
return JsonResponse::create($statuslabel);
|
||||||
$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);
|
|
||||||
}
|
}
|
||||||
|
return JsonResponse::create(["error" => "Failed validation: ".print_r($statuslabel->getErrors()->first(), true)], 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,11 +75,11 @@ class Statuslabel extends Model
|
||||||
$statustype['deployable'] = 0;
|
$statustype['deployable'] = 0;
|
||||||
$statustype['archived'] = 1;
|
$statustype['archived'] = 1;
|
||||||
|
|
||||||
} elseif ($type == 'undeployable') {
|
} else {
|
||||||
$statustype['pending'] = 0;
|
$statustype['pending'] = 0;
|
||||||
$statustype['deployable'] = 0;
|
$statustype['deployable'] = 0;
|
||||||
$statustype['archived'] = 0;
|
$statustype['archived'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $statustype;
|
return $statustype;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue