From b13e04095e2818eaa9b6365b72c3907bae5b9265 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 12 Jul 2017 19:22:58 -0700 Subject: [PATCH] Removed commented code --- .../Controllers/Api/AssetModelsController.php | 1 - .../Api/CustomFieldsetsController.php | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index e70bf3dfa9..6fd3677fc7 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -74,7 +74,6 @@ class AssetModelsController extends Controller $this->authorize('create', AssetModel::class); $assetmodel = new AssetModel; $assetmodel->fill($request->all()); - //$assetmodel->fieldset_id = $request->get("custom_fieldset_id"); if ($assetmodel->save()) { return response()->json(Helper::formatStandardApiResponse('success', $assetmodel, trans('admin/assetmodels/message.create.success'))); diff --git a/app/Http/Controllers/Api/CustomFieldsetsController.php b/app/Http/Controllers/Api/CustomFieldsetsController.php index dec63dc311..ac922e9e81 100644 --- a/app/Http/Controllers/Api/CustomFieldsetsController.php +++ b/app/Http/Controllers/Api/CustomFieldsetsController.php @@ -69,4 +69,30 @@ class CustomFieldsetsController extends Controller } + + /** + * Delete a custom fieldset. + * + * @author [A. Gianotto] [] + * @since [v4.0] + * @return Redirect + */ + public function destroy($id) + { + $this->authorize('delete', CustomFieldset::class); + $fieldset = CustomFieldset::findOrFail($id); + + $modelsCount = $fieldset->models->count(); + $fieldsCount = $fieldset->fields->count(); + + if (($modelsCount > 0) || ($fieldsCount > 0) ){ + return response()->json(Helper::formatStandardApiResponse('error', null, 'Fieldset is in use.')); + } else { + $fieldset->delete(); + return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/custom_fields/message.fieldset.delete.success'))); + } + + + } + }