Merge pull request #3 from bagisto/master

merge with head to base forks
This commit is contained in:
Prashant Singh 2018-12-26 15:11:23 +05:30 committed by GitHub
commit bb6eb04b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 83 deletions

View File

@ -10,15 +10,15 @@
$key = $item['key'];
$key = explode(".", $key);
array_shift($key);
$firstField = current($key);
$secondField = next($key);
$key = implode(".", $key);
$thirdField = end($key);
$name = $item['key'] . '.' . $field['name'];
$name = $key . '.' . $field['name'];
?>
<div class="control-group {{ $field['type'] }}" :class="[errors.has('{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]') ? 'has-error' : '']">
<div class="control-group {{ $field['type'] }}" :class="[errors.has('{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]') ? 'has-error' : '']">
<label for="{{ $name }}" {{ !isset($field['validation']) || strpos('required', $field['validation']) < 0 ? '' : 'class=required' }}>
{{ $field['title'] }}
@ -44,15 +44,18 @@
@if ($field['type'] == 'text')
<input type="text" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as="&quot;{{ $field['name'] }}&quot;">
<input type="text" v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" value="{{ old($name) ?: core()->getConfigData($name) }}" data-vv-as="&quot;{{ $field['name'] }}&quot;">
@elseif ($field['type'] == 'textarea')
<textarea v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" data-vv-as="&quot;{{ $field['name'] }}&quot;">{{ old($name) ?: core()->getConfigData($name) }}</textarea>
<textarea v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" data-vv-as="&quot;{{ $field['name'] }}&quot;">{{ old($name) ?: core()->getConfigData($name) }}</textarea>
@elseif ($field['type'] == 'select')
<select v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" data-vv-as="&quot;{{ $field['name'] }}&quot;" >
<select v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" data-vv-as="&quot;{{ $field['name'] }}&quot;" >
@foreach($field['options'] as $option)
<?php
if($option['value'] == false) {
$value = 0;
@ -67,8 +70,10 @@
{{ $option['title'] }}
</option>
@endforeach
</select>
@endif
<span class="control-error" v-if="errors.has('{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]')">@{{ errors.first('{!! $firstField !!}[{!! $secondField !!}][{!! $field['name'] !!}]') }}</span>
<span class="control-error" v-if="errors.has('{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]')">@{{ errors.first('{!! $firstField !!}[{!! $secondField !!}][{!! $thirdField !!}][{!! $field['name'] !!}]') }}</span>
</div>

View File

@ -545,8 +545,13 @@ class Core
}
}
if(!$coreConfigValue)
if (!$coreConfigValue) {
$fields = explode(".", $field);
array_shift($fields);
$field = implode(".", $fields);
return Config::get($field);
}
return $coreConfigValue->value;
}
@ -692,12 +697,7 @@ class Core
if (isset($coreData['fields'])) {
foreach ($coreData['fields'] as $field) {
$key = $coreData['key'];
$key = explode(".", $key);
array_shift($key);
$key = implode(".", $key);
$name = $key . '.' . $field['name'];
$name = $coreData['key'] . '.' . $field['name'];
if ($name == $fieldName ) {
return $field;

View File

@ -38,14 +38,10 @@ class CoreConfigRepository extends Repository
unset($data['channel']);
}
foreach ($data as $method => $value)
{
foreach ($value as $key => $formData)
{
foreach (array_keys($formData) as $title)
{
$fieldName = $method . '.' . $key . '.' .$title;
$value = $formData[$title];
foreach ($data as $method => $fieldData) {
$recurssiveData = $this->recuressiveArray($fieldData , $method);
foreach ($recurssiveData as $fieldName => $value) {
$field = core()->getConfigField($fieldName);
$channel_based = false;
@ -116,5 +112,29 @@ class CoreConfigRepository extends Repository
}
}
}
/**
* @param array $formData
* @param string $method
* @return array
*/
public function recuressiveArray(array $formData, $method) {
static $data =[];
foreach ($formData as $form => $formValue) {
$value = $method . '.' . $form;
if (is_array($formValue)) {
$this->recuressiveArray($formValue, $value);
} else {
$data[$value] = $formValue;
}
}
return $data;
}
}