mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -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()
|
||||
{
|
||||
|
||||
// create a new model instance
|
||||
// create a new status label instance
|
||||
$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
|
||||
$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);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue