A free open source IT asset/license management system
does a collect and map instead of a for loop for the array solution
Godfrey M70f26f33a58c
diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.phpindex 379836758b..f68e38a42b 100755--- a/app/Http/Controllers/LabelsController.php+++ b/app/Http/Controllers/LabelsController.php@@ -74,16 +74,16 @@ class LabelsController extends Controller$exampleAsset->model->category->id = 999999;$exampleAsset->model->category->name = trans('admin/labels/table.example_category');}- //turns a multidimensional array in an associative array for no double for looping- $result = array();- foreach ($data as $entry) {- $result[key($entry)] = reset($entry);- }- foreach($result as $key => $value) {++ //turns a multidimensional array in an associative array+ $field_selections = collect($data)->mapWithKeys(function ($item) {+ return $item;+ })->toArray();++ foreach($field_selections as $key => $value) {$exampleAsset->{$value} = "{{$key}}";}-$settings = Setting::getSettings();if (request()->has('settings')) {$overrides = request()->get('settings');