Commit 8a38022d authored by Nicolas Widart's avatar Nicolas Widart

Add module settings update ability

parent 8e0e5b01
......@@ -52,9 +52,4 @@ class SettingController extends AdminBaseController
return View::make('setting::admin.module-settings', compact('module', 'moduleSettings', 'settings'));
}
public function postModuleSettings($module)
{
dd('Module settings posted');
}
}
......@@ -4,7 +4,7 @@ $router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'Larav
$router->group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Setting\Http\Controllers'], function($router)
{
$router->get('settings/{module}', ['as' => 'dashboard.module.settings', 'uses' => 'Admin\SettingController@getModuleSettings']);
$router->post('settings/{module}', ['as' => 'dashboard.module.settings.post', 'uses' => 'Admin\SettingController@postModuleSettings']);
$router->post('settings', ['as' => 'dashboard.module.settings.post', 'uses' => 'Admin\SettingController@postModuleSettings']);
$router->resource('settings', 'Admin\SettingController', ['except' => ['show', 'edit', 'update', 'destroy', 'create'], 'names' => [
'index' => 'dashboard.setting.index',
'store' => 'dashboard.setting.store'
......
......@@ -149,7 +149,12 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/
public function savedModuleSettings($module)
{
return $this->findByModule($module);
$moduleSettings = [];
foreach ($this->findByModule($module) as $setting) {
$moduleSettings[$setting->name] = $setting;
}
return $moduleSettings;
}
/**
......@@ -159,6 +164,6 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/
private function findByModule($module)
{
return $this->model->where('name', "$module%")->get();
return $this->model->where('name', 'LIKE', $module . '_%')->get();
}
}
......@@ -13,7 +13,7 @@
@section('content')
@include('flash::message')
{!! Form::open(['route' => ['dashboard.module.settings.post', $module], 'method' => 'post']) !!}
{!! Form::open(['route' => ['dashboard.module.settings.post'], 'method' => 'post']) !!}
<div class="row">
<div class="col-md-12">
<div class="box box-info">
......@@ -25,10 +25,10 @@
</ul>
<div class="tab-content">
<div class="tab-pane {{ App::getLocale() == 'en' ? 'active' : '' }}" id="tab_1-1">
@include('setting::admin.partials.module-fields', ['lang' => 'en', 'moduleSettings' => $moduleSettings, 'settings' => $settings])
@include('setting::admin.partials.module-fields', ['lang' => 'en', 'moduleSettings' => $moduleSettings, 'settings' => $settings, 'module' => $module])
</div>
<div class="tab-pane {{ App::getLocale() == 'fr' ? 'active' : '' }}" id="tab_2-2">
@include('setting::admin.partials.module-fields', ['lang' => 'fr', 'moduleSettings' => $moduleSettings, 'settings' => $settings])
@include('setting::admin.partials.module-fields', ['lang' => 'fr', 'moduleSettings' => $moduleSettings, 'settings' => $settings, 'module' => $module])
</div>
</div>
</div>
......
<?php foreach($moduleSettings as $setting => $description): ?>
<?php $settingName = $module . '_' . $setting; ?>
<div class='form-group'>
{!! Form::label($setting . "[$lang]", $description) !!}
<?php if (count($settings) >= 1): ?>
{!! Form::text($setting . "[$lang]", Input::old($setting . "[$lang]", $settings[$setting]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $description]) !!}
{!! Form::label($settingName . "[$lang]", $description) !!}
<?php if (isset($settings[$settingName])): ?>
{!! Form::text($settingName . "[$lang]", Input::old($settingName . "[$lang]", $settings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $description]) !!}
<?php else: ?>
{!! Form::text($setting . "[$lang]", Input::old($setting . "[$lang]"), ['class' => 'form-control', 'placeholder' => $description]) !!}
{!! Form::text($settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $description]) !!}
<?php endif; ?>
</div>
<?php endforeach; ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment