A free open source IT asset/license management system
Handle use case where there are no custom fields for any assigned models
snipe1122562b4eba
diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.phpindex 55499ab22b..7f5343ede2 100755--- a/app/Http/Controllers/ViewAssetsController.php+++ b/app/Http/Controllers/ViewAssetsController.php@@ -38,14 +38,19 @@ class ViewAssetsController extends Controller'licenses',)->find(Auth::user()->id);+ $field_array = array();+// Loop through all the custom fields that are applied to any model the user has assignedforeach ($user->assets as $asset) {- foreach ($asset->model->fieldset->fields as $field) {- // check and make sure they're allowed to see the value of the custom field- if ($field->display_in_user_view == '1') {- $field_array[$field->db_column] = $field->name;+ if ($asset->model->fieldset) {+ foreach ($asset->model->fieldset->fields as $field) {+ // check and make sure they're allowed to see the value of the custom field+ if ($field->display_in_user_view == '1') {+ $field_array[$field->db_column] = $field->name;+ }}}+}// Since some models may re-use the same fieldsets/fields, let's make the array unique so we don't repeat columns