diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 8a32dc3e44..f3c65541da 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -49,6 +49,10 @@ class BulkAssetsController extends Controller })->get(); $models = $asset_custom_field->unique('model_id'); + $modelNames = []; + foreach($models as $model) { + $modelNames[] = $model->name; + } ray($asset_custom_field); ray($models); @@ -78,7 +82,8 @@ class BulkAssetsController extends Controller ->with('assets', $asset_ids) ->with('statuslabel_list', Helper::statusLabelList()) // ->with('custom_fields', $custom_fields) - ->with('models', $models->pluck('model')); + ->with('models', $models->pluck('model')) + ->with('modelNames', $modelNames); } } diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index 46a33548dd..55738cd034 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -181,8 +181,6 @@ class CustomField extends Model public function assetModels() { return $this->fieldset()->with('models')->get()->pluck('models')->flatten()->unique('id'); - - // return $this->models->where(, AssetModel::class); } /** diff --git a/resources/views/models/custom_fields_form_bulk_edit.blade.php b/resources/views/models/custom_fields_form_bulk_edit.blade.php index c932c0be41..123472830c 100644 --- a/resources/views/models/custom_fields_form_bulk_edit.blade.php +++ b/resources/views/models/custom_fields_form_bulk_edit.blade.php @@ -1,23 +1,21 @@ @php +//set array up before loop so it doesn't get wiped at every iteration $fields = []; - $modelNames = []; - foreach($models as $model) { - $modelNames[] = $model->name; - } @endphp @foreach($models as $model) @if (($model) && ($model->fieldset)) @foreach($model->fieldset->fields AS $field) - - @php - if (in_array($field->db_column_name(), $fields)) { - $duplicate = true; - continue; - } else { - $duplicate = false; - } - $fields[] = $field->db_column_name(); - @endphp + @php + //prevents some duplicate queries - open to a better way of skipping dupes in output + //its ugly, but if we'd rather deal with duplicate queries we can get rid of this. + if (in_array($field->db_column_name(), $fields)) { + $duplicate = true; + continue; + } else { + $duplicate = false; + } + $fields[] = $field->db_column_name(); + @endphp