mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Check that the field is valid before checking to see count()
This mostly affects the demo, since the seeder updates info often Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
e286ff0be3
commit
c17eaaad69
|
@ -151,11 +151,11 @@ class CustomFieldsController extends Controller
|
|||
*/
|
||||
public function destroy($field_id)
|
||||
{
|
||||
$field = CustomField::find($field_id);
|
||||
if ($field = CustomField::find($field_id)) {
|
||||
|
||||
$this->authorize('delete', $field);
|
||||
|
||||
if ($field->fieldset->count()>0) {
|
||||
if (($field->fieldset) && ($field->fieldset->count() > 0)) {
|
||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
||||
}
|
||||
$field->delete();
|
||||
|
@ -163,6 +163,9 @@ class CustomFieldsController extends Controller
|
|||
->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withErrors(['message' => "Field does not exist"]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a view to edit a custom field
|
||||
|
|
Loading…
Reference in a new issue