configuration changes
This commit is contained in:
parent
405e8bfecb
commit
9bb9ae5ce7
|
|
@ -82,7 +82,7 @@ class ConfigurationController extends Controller
|
|||
$slugs = $this->getDefaultConfigSlugs();
|
||||
|
||||
if(count($slugs)) {
|
||||
return redirect()->route('admin.configuration.index', $slugs);
|
||||
return redirect()->route('admin.configuration.index', $slugs);
|
||||
}
|
||||
|
||||
return view($this->_config['view'], ['config' => $this->configTree]);
|
||||
|
|
|
|||
|
|
@ -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,15 @@
|
|||
|
||||
@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=""{{ $field['name'] }}"">
|
||||
<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=""{{ $field['name'] }}"">
|
||||
|
||||
@elseif ($field['type'] == 'textarea')
|
||||
|
||||
<textarea v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $field['name'] }}]" data-vv-as=""{{ $field['name'] }}"">{{ 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=""{{ $field['name'] }}"">{{ 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=""{{ $field['name'] }}"" >
|
||||
<select v-validate="'{{ $validations }}'" class="control" id="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" name="{{ $firstField }}[{{ $secondField }}][{{ $thirdField }}][{{ $field['name'] }}]" data-vv-as=""{{ $field['name'] }}"" >
|
||||
|
||||
@foreach($field['options'] as $option)
|
||||
|
||||
|
|
@ -75,5 +75,5 @@
|
|||
|
||||
@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>
|
||||
|
|
@ -530,8 +530,13 @@ class Core
|
|||
}
|
||||
}
|
||||
|
||||
if(!$coreConfigValue)
|
||||
if (!$coreConfigValue) {
|
||||
$fields = explode(".", $field);
|
||||
array_shift($fields);
|
||||
$field = implode(".", $fields);
|
||||
|
||||
return Config::get($field);
|
||||
}
|
||||
|
||||
return $coreConfigValue->value;
|
||||
}
|
||||
|
|
@ -677,12 +682,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;
|
||||
|
|
|
|||
|
|
@ -38,83 +38,103 @@ class CoreConfigRepository extends Repository
|
|||
unset($data['channel']);
|
||||
}
|
||||
|
||||
foreach ($data as $method => $value)
|
||||
{
|
||||
foreach ($value as $key => $formData)
|
||||
{
|
||||
foreach (array_keys($formData) as $title)
|
||||
foreach ($data as $method => $fieldData) {
|
||||
$recurssiveData = $this->recuressiveArray($fieldData , $method);
|
||||
|
||||
foreach ($recurssiveData as $fieldName => $value) {
|
||||
$field = core()->getConfigField($fieldName);
|
||||
|
||||
$channel_based = false;
|
||||
$locale_based = false;
|
||||
|
||||
if (isset($field['channel_based']) && $field['channel_based']) {
|
||||
$channel_based = true;
|
||||
}
|
||||
|
||||
if (isset($field['locale_based']) && $field['locale_based']) {
|
||||
$locale_based = true;
|
||||
}
|
||||
|
||||
if (isset($field['channel_based']) && $field['channel_based'])
|
||||
{
|
||||
$fieldName = $method . '.' . $key . '.' .$title;
|
||||
$value = $formData[$title];
|
||||
$field = core()->getConfigField($fieldName);
|
||||
|
||||
$channel_based = false;
|
||||
$locale_based = false;
|
||||
|
||||
if (isset($field['channel_based']) && $field['channel_based']) {
|
||||
$channel_based = true;
|
||||
if (isset($field['locale_based']) && $field['locale_based'])
|
||||
{
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->where('locale_code', $locale)
|
||||
->where('channel_code', $channel)
|
||||
->get();
|
||||
}
|
||||
|
||||
if (isset($field['locale_based']) && $field['locale_based']) {
|
||||
$locale_based = true;
|
||||
else
|
||||
{
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->where('channel_code', $channel)
|
||||
->get();
|
||||
}
|
||||
|
||||
if (isset($field['channel_based']) && $field['channel_based'])
|
||||
} else
|
||||
{
|
||||
if (isset($field['locale_based']) && $field['locale_based'])
|
||||
{
|
||||
if (isset($field['locale_based']) && $field['locale_based'])
|
||||
{
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->where('locale_code', $locale)
|
||||
->where('channel_code', $channel)
|
||||
->get();
|
||||
}
|
||||
else
|
||||
{
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->where('channel_code', $channel)
|
||||
->get();
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (isset($field['locale_based']) && $field['locale_based'])
|
||||
{
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->where('locale_code', $locale)
|
||||
->get();
|
||||
}
|
||||
else
|
||||
{
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->get();
|
||||
}
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->where('locale_code', $locale)
|
||||
->get();
|
||||
}
|
||||
|
||||
if (!count($coreConfigValue) > 0)
|
||||
else
|
||||
{
|
||||
$this->model->create([
|
||||
'code' => $fieldName,
|
||||
'value' => $value,
|
||||
'locale_code' => $locale_based ? $locale : null,
|
||||
'channel_code' => $channel_based ? $channel : null
|
||||
]);
|
||||
} else
|
||||
{
|
||||
$updataData['code'] = $fieldName;
|
||||
$updataData['value'] = $value;
|
||||
$updataData['locale_code'] = $locale_based ? $locale : null;
|
||||
$updataData['channel_code'] = $channel_based ? $channel : null;
|
||||
$coreConfigValue = $this->model
|
||||
->where('code', $fieldName)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($coreConfigValue as $coreConfig)
|
||||
{
|
||||
$coreConfig->update($updataData);
|
||||
}
|
||||
if (!count($coreConfigValue) > 0)
|
||||
{
|
||||
$this->model->create([
|
||||
'code' => $fieldName,
|
||||
'value' => $value,
|
||||
'locale_code' => $locale_based ? $locale : null,
|
||||
'channel_code' => $channel_based ? $channel : null
|
||||
]);
|
||||
} else
|
||||
{
|
||||
$updataData['code'] = $fieldName;
|
||||
$updataData['value'] = $value;
|
||||
$updataData['locale_code'] = $locale_based ? $locale : null;
|
||||
$updataData['channel_code'] = $channel_based ? $channel : null;
|
||||
|
||||
foreach ($coreConfigValue as $coreConfig)
|
||||
{
|
||||
$coreConfig->update($updataData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
const { mix } = require("laravel-mix");
|
||||
require("laravel-mix-merge-manifest");
|
||||
|
||||
// var publicPath = 'publishable/assets';
|
||||
var publicPath = "../../../public/vendor/webkul/ui/assets";
|
||||
var publicPath = 'publishable/assets';
|
||||
// var publicPath = "../../../public/vendor/webkul/ui/assets";
|
||||
|
||||
mix.setPublicPath(publicPath).mergeManifest();
|
||||
mix.disableNotifications();
|
||||
|
|
|
|||
Loading…
Reference in New Issue