mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-12 16:44:08 -08:00
Store new fields in the database
This commit is contained in:
parent
406d270c01
commit
43fbd54a12
|
@ -128,24 +128,33 @@ class CustomFieldsController extends Controller
|
||||||
* @since [v1.8]
|
* @since [v1.8]
|
||||||
* @return Redirect
|
* @return Redirect
|
||||||
*/
|
*/
|
||||||
public function storeField()
|
public function storeField(Request $request)
|
||||||
{
|
{
|
||||||
$field=new CustomField(["name" => Input::get("name"),"element" => Input::get("element"),"user_id" => Auth::user()->id]);
|
$field = new CustomField([
|
||||||
|
"name" => e($request->get("name")),
|
||||||
|
"element" => e($request->get("element")),
|
||||||
|
"field_values" => e($request->get("field_values")),
|
||||||
|
"field_encrypted" => e($request->get("field_encrypted", 0)),
|
||||||
|
"user_id" => Auth::user()->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
|
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
|
||||||
$field->format=Input::get("custom_format");
|
$field->format = e($request->get("custom_format"));
|
||||||
} else {
|
} else {
|
||||||
$field->format=Input::get('format');
|
$field->format = e($request->get("format"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$validator=Validator::make(Input::all(), $field->rules);
|
$validator=Validator::make(Input::all(), $field->rules);
|
||||||
if ($validator->passes()) {
|
if ($validator->passes()) {
|
||||||
$results=$field->save();
|
$results = $field->save();
|
||||||
//return "postCreateField: $results";
|
|
||||||
if ($results) {
|
if ($results) {
|
||||||
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.create.success'));
|
return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.create.success'));
|
||||||
} else {
|
} else {
|
||||||
|
dd($field);
|
||||||
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.create.error'));
|
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.create.error'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,9 +190,7 @@ class CustomFieldsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function deleteField($field_id)
|
public function deleteField($field_id)
|
||||||
{
|
{
|
||||||
$field=CustomField::find($field_id);
|
$field = CustomField::find($field_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($field->fieldset->count()>0) {
|
if ($field->fieldset->count()>0) {
|
||||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
||||||
|
|
Loading…
Reference in a new issue