mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
does a collect and map instead of a for loop for the array solution
This commit is contained in:
parent
414bc10c40
commit
70f26f33a5
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue