diff --git a/app/helpers.php b/app/helpers.php index b91736ca..323eaa5b 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,5 +1,26 @@ 'item1', 1 => 'item2'] + * to: + * ['item1' => 'item1', 'item2' => 'item2'] + * + * @param array $list + * @return \Illuminate\Support\Collection + */ + function list_to_assoc(array $list) + { + return collect($list)->mapWithKeys(function ($item) { + return [$item => $item]; + }); + } +} + if (!function_exists('skin_view')) { /** * Render a skin diff --git a/resources/views/admin/settings/table.blade.php b/resources/views/admin/settings/table.blade.php index 36846fc7..02258587 100644 --- a/resources/views/admin/settings/table.blade.php +++ b/resources/views/admin/settings/table.blade.php @@ -23,9 +23,11 @@ @elseif($setting->type === 'int' || $setting->type === 'number') {!! Form::number($setting->id, $setting->value, ['class'=>'form-control']) !!} @elseif($setting->type === 'select') - {!! Form::select($setting->id, - explode(',', $setting->options), - $setting->value, ['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) !!} + {!! Form::select( + $setting->id, + list_to_assoc(explode(',', $setting->options)), + $setting->value, + ['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) !!} @else {!! Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) !!} @endif