mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
removes the double for loop with a better solution
This commit is contained in:
parent
250b0a7afb
commit
414bc10c40
|
@ -27,7 +27,7 @@ class LabelsController extends Controller
|
||||||
public function show(string $labelName)
|
public function show(string $labelName)
|
||||||
{
|
{
|
||||||
$setting = Setting::getSettings();
|
$setting = Setting::getSettings();
|
||||||
//This part allows for the custom selection label preview
|
//This part allows for the custom field selection to be visible in the label preview
|
||||||
$data = explode(';', Setting::getSettings()->label2_fields);
|
$data = explode(';', Setting::getSettings()->label2_fields);
|
||||||
$data = array_map(function($element) {
|
$data = array_map(function($element) {
|
||||||
$a = explode('=', $element);
|
$a = explode('=', $element);
|
||||||
|
@ -74,12 +74,15 @@ class LabelsController extends Controller
|
||||||
$exampleAsset->model->category->id = 999999;
|
$exampleAsset->model->category->id = 999999;
|
||||||
$exampleAsset->model->category->name = trans('admin/labels/table.example_category');
|
$exampleAsset->model->category->name = trans('admin/labels/table.example_category');
|
||||||
}
|
}
|
||||||
|
//turns a multidimensional array in an associative array for no double for looping
|
||||||
foreach($data as $innerArray){
|
$result = array();
|
||||||
foreach($innerArray as $key => $value) {
|
foreach ($data as $entry) {
|
||||||
$exampleAsset->{$value} = "{{$key}}";
|
$result[key($entry)] = reset($entry);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
foreach($result as $key => $value) {
|
||||||
|
$exampleAsset->{$value} = "{{$key}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$settings = Setting::getSettings();
|
$settings = Setting::getSettings();
|
||||||
if (request()->has('settings')) {
|
if (request()->has('settings')) {
|
||||||
|
|
Loading…
Reference in a new issue