From f2499fc7d22f76ed4e6e5c36543105b20ab571ef Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 26 Oct 2017 22:33:40 -0700 Subject: [PATCH] Removed else condition on custom fields API for code quality --- app/Http/Controllers/Api/CustomFieldsController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/CustomFieldsController.php b/app/Http/Controllers/Api/CustomFieldsController.php index 38976d2840..43100f8faa 100644 --- a/app/Http/Controllers/Api/CustomFieldsController.php +++ b/app/Http/Controllers/Api/CustomFieldsController.php @@ -57,15 +57,15 @@ class CustomFieldsController extends Controller */ public function destroy($field_id) { - $field = CustomField::find($field_id); + $field = CustomField::findOrFail($field_id); if ($field->fieldset->count() >0) { return response()->json(Helper::formatStandardApiResponse('error', null, 'Field is in use.')); - } else { - $field->delete(); - return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/custom_fields/message.field.delete.success'))); - } + + $field->delete(); + return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/custom_fields/message.field.delete.success'))); + } }