mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
moves the array manipulation up the page where it should be
This commit is contained in:
parent
529310c93a
commit
83474d6e59
|
@ -27,13 +27,18 @@ 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 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 = explode(';', Setting::getSettings()->label2_fields);
|
||||||
$data = array_map(function($element) {
|
$data = array_map(function($element) {
|
||||||
$a = explode('=', $element);
|
$a = explode('=', $element);
|
||||||
return [$a[0] => $a[1]];
|
return [$a[0] => $a[1]];
|
||||||
}, $data);
|
}, $data);
|
||||||
|
|
||||||
|
//turns a multidimensional array into an associative array
|
||||||
|
$field_selections = collect($data)->mapWithKeys(function ($item) {
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
|
|
||||||
$labelName = str_replace('/', '\\', $labelName);
|
$labelName = str_replace('/', '\\', $labelName);
|
||||||
$template = Label::find($labelName);
|
$template = Label::find($labelName);
|
||||||
|
|
||||||
|
@ -75,10 +80,7 @@ class LabelsController extends Controller
|
||||||
$exampleAsset->model->category->name = trans('admin/labels/table.example_category');
|
$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) {
|
foreach($field_selections as $key => $value) {
|
||||||
$exampleAsset->{$value} = "{{$key}}";
|
$exampleAsset->{$value} = "{{$key}}";
|
||||||
|
|
Loading…
Reference in a new issue