From 9f9f8c173bfe14b0f8b7801d7627dddc2e0823f7 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 31 Oct 2023 10:00:36 -0600 Subject: [PATCH] Add condition to only run trough custom fields if a custom fieldset exist --- app/Models/Asset.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 63df483729..9f15101d33 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -212,9 +212,11 @@ class Asset extends Depreciable $this->rules += $model->fieldset->validation_rules(); - foreach ($this->model->fieldset->fields as $field){ - if($field->format == 'BOOLEAN'){ - $this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN); + if ($this->model->fieldset){ + foreach ($this->model->fieldset->fields as $field){ + if($field->format == 'BOOLEAN'){ + $this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN); + } } } }