A free open source IT asset/license management system
moves the array manipulation up the page where it should be
Godfrey M83474d6e5980
diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.phpindex 3a8ff4faf5..6363ee671a 100755--- a/app/Http/Controllers/LabelsController.php+++ b/app/Http/Controllers/LabelsController.php@@ -27,13 +27,18 @@ class LabelsController extends Controllerpublic function show(string $labelName){$setting = Setting::getSettings();- //This part allows for the custom field selection to be visible in the label preview+ //grabs the field selection selected and turns it into a multidimensional array$data = explode(';', Setting::getSettings()->label2_fields);$data = array_map(function($element) {$a = explode('=', $element);return [$a[0] => $a[1]];}, $data);+ //turns a multidimensional array into an associative array+ $field_selections = collect($data)->mapWithKeys(function ($item) {+ return $item;+ })->toArray();+$labelName = str_replace('/', '\\', $labelName);$template = Label::find($labelName);@@ -75,10 +80,7 @@ class LabelsController extends Controller$exampleAsset->model->category->name = trans('admin/labels/table.example_category');}- //turns a multidimensional array into an associative array- $field_selections = collect($data)->mapWithKeys(function ($item) {- return $item;- })->toArray();+foreach($field_selections as $key => $value) {$exampleAsset->{$value} = "{{$key}}";