Commit 6a966cc8 authored by Nicolas Widart's avatar Nicolas Widart

Squashed 'Modules/Setting/' changes from 7bcb95b..a5c8be9

a5c8be9 Removing duplication
9689930 Implement new setting interface
9fc8208 Cleaning up the settings class
e89e082 Adding a settings facade
b3018ea Preparing the reader
0d68e33 Adding active state to current module
21633a5 Remove unneeded view
c4b3ded Rearrange settings for modularity
9936bc9 Preparing the reader class
f67260e Checking for settings
75b03e0 Change the seperator
5f78840 Rename setting seperator
3dd5b34 Add base support classes
47b0587 Renaming column
16a1c35 Adding not translatable settings
1965928 Adding plain settings fields
f540707 Loop over all the available languages
6da0313 Shortening settings name
df527a1 Renaming fields partials
c3528eb Moving the translatable fields over
9cf4383 Adding 2 more columns

git-subtree-dir: Modules/Setting
git-subtree-split: a5c8be95109e3b7cbc86925d1d0027885182e1b5
parent 9e9f8095
...@@ -15,6 +15,8 @@ class CreateSettingsTable extends Migration ...@@ -15,6 +15,8 @@ class CreateSettingsTable extends Migration
Schema::create('settings', function (Blueprint $table) { Schema::create('settings', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('name'); $table->string('name');
$table->string('plainValue');
$table->boolean('isTranslatable');
$table->timestamps(); $table->timestamps();
}); });
} }
......
...@@ -8,5 +8,5 @@ class Setting extends Model ...@@ -8,5 +8,5 @@ class Setting extends Model
use Translatable; use Translatable;
public $translatedAttributes = ['value', 'description']; public $translatedAttributes = ['value', 'description'];
protected $fillable = ['name', 'value', 'description']; protected $fillable = ['name', 'value', 'description', 'isTranslatable', 'plainValue'];
} }
<?php namespace Modules\Setting\Facades;
use Illuminate\Support\Facades\Facade;
class Settings extends Facade
{
protected static function getFacadeAccessor() { return 'setting.settings'; }
}
...@@ -29,11 +29,7 @@ class SettingController extends AdminBaseController ...@@ -29,11 +29,7 @@ class SettingController extends AdminBaseController
public function index() public function index()
{ {
$settings = $this->setting->all(); return Redirect::route('dashboard.module.settings', ['core']);
$modulesWithSettings = $this->setting->moduleSettings($this->module->enabled());
return View::make('setting::admin.settings', compact('settings', 'modulesWithSettings'));
} }
public function store(SettingRequest $request) public function store(SettingRequest $request)
...@@ -44,12 +40,16 @@ class SettingController extends AdminBaseController ...@@ -44,12 +40,16 @@ class SettingController extends AdminBaseController
return Redirect::route('dashboard.setting.index'); return Redirect::route('dashboard.setting.index');
} }
public function getModuleSettings($module) public function getModuleSettings($currentModule)
{ {
$moduleSettings = $this->setting->moduleSettings($module); $modulesWithSettings = $this->setting->moduleSettings($this->module->enabled());
$translatableSettings = $this->setting->translatableModuleSettings($currentModule);
$plainSettings = $this->setting->plainModuleSettings($currentModule);
$settings = $this->setting->savedModuleSettings($module); $dbSettings = $this->setting->savedModuleSettings($currentModule);
return View::make('setting::admin.module-settings', compact('module', 'moduleSettings', 'settings')); return View::make('setting::admin.module-settings',
compact('currentModule', 'translatableSettings', 'plainSettings', 'dbSettings', 'modulesWithSettings'));
} }
} }
<?php namespace Modules\Setting\Providers; <?php namespace Modules\Setting\Providers;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Setting\Entities\Setting; use Modules\Setting\Entities\Setting;
use Modules\Setting\Repositories\Eloquent\EloquentSettingRepository; use Modules\Setting\Repositories\Eloquent\EloquentSettingRepository;
use Modules\Setting\Support\Settings;
class SettingServiceProvider extends ServiceProvider { class SettingServiceProvider extends ServiceProvider {
...@@ -23,6 +25,17 @@ class SettingServiceProvider extends ServiceProvider { ...@@ -23,6 +25,17 @@ class SettingServiceProvider extends ServiceProvider {
$this->app->booted(function () { $this->app->booted(function () {
$this->registerBindings(); $this->registerBindings();
}); });
$this->app['setting.settings'] = $this->app->share(function($app)
{
return new Settings($app['Modules\Setting\Repositories\SettingRepository']);
});
$this->app->booting(function()
{
$loader = AliasLoader::getInstance();
$loader->alias('Settings', 'Modules\Setting\Facades\Settings');
});
} }
/** /**
...@@ -43,5 +56,9 @@ class SettingServiceProvider extends ServiceProvider { ...@@ -43,5 +56,9 @@ class SettingServiceProvider extends ServiceProvider {
return new EloquentSettingRepository(new Setting); return new EloquentSettingRepository(new Setting);
} }
); );
$this->app->bind(
'Modules\Core\Contracts\Setting',
'Modules\Setting\Support\Settings'
);
} }
} }
...@@ -50,7 +50,6 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin ...@@ -50,7 +50,6 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
$this->removeTokenKey($settings); $this->removeTokenKey($settings);
foreach ($settings as $settingName => $settingValues) { foreach ($settings as $settingName => $settingValues) {
// Check if setting exists
if ($setting = $this->findByName($settingName)) { if ($setting = $this->findByName($settingName)) {
$this->updateSetting($setting, $settingValues); $this->updateSetting($setting, $settingValues);
continue; continue;
...@@ -75,24 +74,26 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin ...@@ -75,24 +74,26 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/ */
public function findByName($settingName) public function findByName($settingName)
{ {
return $this->model->whereHas( return $this->model->where('name', $settingName)->first();
'translations',
function ($q) use ($settingName) {
$q->where('name', $settingName);
}
)->first();
} }
/** /**
* Create a setting with the given name * Create a setting with the given name
* @param $settingName * @param string $settingName
* @param $settingValues * @param $settingValues
*/ */
private function createForName($settingName, $settingValues) private function createForName($settingName, $settingValues)
{ {
$setting = new $this->model; $setting = new $this->model;
$setting->name = $settingName; $setting->name = $settingName;
$this->setTranslatedAttributes($settingValues, $setting);
if (is_array($settingValues)) {
$setting->isTranslatable = true;
$this->setTranslatedAttributes($settingValues, $setting);
} else {
$setting->isTranslatable = false;
$setting->plainValue = $settingValues;
}
return $setting->save(); return $setting->save();
} }
...@@ -104,7 +105,11 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin ...@@ -104,7 +105,11 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/ */
private function updateSetting($setting, $settingValues) private function updateSetting($setting, $settingValues)
{ {
$this->setTranslatedAttributes($settingValues, $setting); if (is_array($settingValues)) {
$this->setTranslatedAttributes($settingValues, $setting);
} else {
$setting->plainValue = $settingValues;
}
return $setting->save(); return $setting->save();
} }
...@@ -164,21 +169,40 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin ...@@ -164,21 +169,40 @@ class EloquentSettingRepository extends EloquentBaseRepository implements Settin
*/ */
public function findByModule($module) public function findByModule($module)
{ {
return $this->model->where('name', 'LIKE', $module . '_%')->get(); return $this->model->where('name', 'LIKE', $module . '::%')->get();
} }
/** /**
* Find the given setting name for the given module * Find the given setting name for the given module
* @param $settingName * @param string $settingName
* @return mixed
*/
public function get($settingName)
{
return $this->model->where('name', 'LIKE', "{$settingName}")->first();
}
/**
* Return the translatable module settings
* @param $module * @param $module
* @return mixed * @return mixed
*/ */
public function findSettingForModule($settingName, $module = null) public function translatableModuleSettings($module)
{ {
if (is_null($module)) { return array_filter($this->moduleSettings($module), function($setting) {
return $this->model->where('name', 'LIKE', "%{$settingName}")->first(); return isset($setting['translatable']);
} });
}
return $this->model->where('name', 'LIKE', "{$module}_{$settingName}")->first(); /**
* Return the non translatable module settings
* @param $module
* @return array
*/
public function plainModuleSettings($module)
{
return array_filter($this->moduleSettings($module), function($setting) {
return !isset($setting['translatable']);
});
} }
} }
...@@ -42,9 +42,22 @@ interface SettingRepository extends BaseRepository ...@@ -42,9 +42,22 @@ interface SettingRepository extends BaseRepository
/** /**
* Find the given setting name for the given module * Find the given setting name for the given module
* @param $settingName * @param string $settingName
* @param $module
* @return mixed * @return mixed
*/ */
public function findSettingForModule($settingName, $module = null); public function get($settingName);
/**
* Return the translatable module settings
* @param $module
* @return array
*/
public function translatableModuleSettings($module);
/**
* Return the non translatable module settings
* @param $module
* @return array
*/
public function plainModuleSettings($module);
} }
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox">
<label for="{{ $settingName }}">
<input id="{{ $settingName }}"
name="{{ $settingName }}"
type="checkbox"
class="flat-blue"
{{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->value == true ? 'checked' : '' }}
value="1" />
{{ $moduleInfo['description'] }}
</label>
</div>
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName, $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
{!! Form::input('number', $settingName, Input::old($settingName, $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?>
{!! Form::input('number', $settingName, Input::old($settingName), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?>
</div>
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox">
<?php foreach($moduleInfo['options'] as $value => $optionName): ?>
<label for="{{ $optionName }}">
<input id="{{ $optionName }}"
name="{{ $settingName }}"
type="radio"
class="flat-blue"
{{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->value == $value ? 'checked' : '' }}
value="{{ $value }}" />
{{ $optionName }}
</label>
<?php endforeach; ?>
</div>
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName, $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
{!! Form::text($settingName, Input::old($settingName, $dbSettings[$settingName]->plainValue), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?>
{!! Form::text($settingName, Input::old($settingName), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?>
</div>
<?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'>
{!! Form::label($settingName", $moduleInfo['description']) !!}
<?php if (isset($dbSettings[$settingName])): ?>
{!! Form::textarea($settingName", Input::old($settingName", $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?>
{!! Form::textarea($settingName", Input::old($settingName"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?>
</div>
<?php $settingName = $module . '_' . $setting; ?> <?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox"> <div class="checkbox">
<label for="{{ $settingName . "[$lang]" }}"> <label for="{{ $settingName . "[$lang]" }}">
<input id="{{ $settingName . "[$lang]" }}" <input id="{{ $settingName . "[$lang]" }}"
name="{{ $settingName . "[$lang]" }}" name="{{ $settingName . "[$lang]" }}"
type="checkbox" type="checkbox"
class="flat-blue" class="flat-blue"
{{ isset($settings[$settingName]) && (bool)$settings[$settingName]->translate($lang)->value == true ? 'checked' : '' }} {{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->translate($lang)->value == true ? 'checked' : '' }}
value="1" /> value="1" />
{{ $moduleInfo['description'] }} {{ $moduleInfo['description'] }}
</label> </label>
......
<?php $settingName = $module . '_' . $setting; ?> <?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'> <div class='form-group'>
{!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!} {!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!}
<?php if (isset($settings[$settingName])): ?> <?php if (isset($dbSettings[$settingName])): ?>
{!! Form::input('number', $settingName . "[$lang]", Input::old($settingName . "[$lang]", $settings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!} {!! Form::input('number', $settingName . "[$lang]", Input::old($settingName . "[$lang]", $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?> <?php else: ?>
{!! Form::input('number', $settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!} {!! Form::input('number', $settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?> <?php endif; ?>
......
<?php $settingName = $module . '_' . $setting; ?> <?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class="checkbox"> <div class="checkbox">
<?php foreach($moduleInfo['options'] as $value => $optionName): ?> <?php foreach($moduleInfo['options'] as $value => $optionName): ?>
<label for="{{ $optionName . "[$lang]" }}"> <label for="{{ $optionName . "[$lang]" }}">
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
name="{{ $settingName . "[$lang]" }}" name="{{ $settingName . "[$lang]" }}"
type="radio" type="radio"
class="flat-blue" class="flat-blue"
{{ isset($settings[$settingName]) && (bool)$settings[$settingName]->translate($lang)->value == $value ? 'checked' : '' }} {{ isset($dbSettings[$settingName]) && (bool)$dbSettings[$settingName]->translate($lang)->value == $value ? 'checked' : '' }}
value="{{ $value }}" /> value="{{ $value }}" />
{{ $optionName }} {{ $optionName }}
</label> </label>
......
<?php $settingName = $module . '_' . $setting; ?> <?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'> <div class='form-group'>
{!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!} {!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!}
<?php if (isset($settings[$settingName])): ?> <?php if (isset($dbSettings[$settingName])): ?>
{!! Form::text($settingName . "[$lang]", Input::old($settingName . "[$lang]", $settings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!} {!! Form::text($settingName . "[$lang]", Input::old($settingName . "[$lang]", $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?> <?php else: ?>
{!! Form::text($settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!} {!! Form::text($settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?> <?php endif; ?>
......
<?php $settingName = $module . '_' . $setting; ?> <?php $settingName = strtolower($currentModule) . '::' . $setting; ?>
<div class='form-group'> <div class='form-group'>
{!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!} {!! Form::label($settingName . "[$lang]", $moduleInfo['description']) !!}
<?php if (isset($settings[$settingName])): ?> <?php if (isset($dbSettings[$settingName])): ?>
{!! Form::textarea($settingName . "[$lang]", Input::old($settingName . "[$lang]", $settings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!} {!! Form::textarea($settingName . "[$lang]", Input::old($settingName . "[$lang]", $dbSettings[$settingName]->translate($lang)->value), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php else: ?> <?php else: ?>
{!! Form::textarea($settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!} {!! Form::textarea($settingName . "[$lang]", Input::old($settingName . "[$lang]"), ['class' => 'form-control', 'placeholder' => $moduleInfo['description']]) !!}
<?php endif; ?> <?php endif; ?>
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
@section('content-header') @section('content-header')
<h1> <h1>
{{ trans('setting::settings.title.module name settings', ['module' => ucfirst($module)]) }} {{ trans('setting::settings.title.module name settings', ['module' => ucfirst($currentModule)]) }}
</h1> </h1>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> {{ trans('core::core.breadcrumb.home') }}</a></li> <li><a href="#"><i class="fa fa-dashboard"></i> {{ trans('core::core.breadcrumb.home') }}</a></li>
<li><a href="{{ URL::route('dashboard.setting.index') }}"><i class="fa fa-cog"></i> {{ trans('setting::settings.breadcrumb.settings') }}</a></li> <li><a href="{{ URL::route('dashboard.setting.index') }}"><i class="fa fa-cog"></i> {{ trans('setting::settings.breadcrumb.settings') }}</a></li>
<li class="active"><i class="fa fa-cog"></i> {{ trans('setting::settings.breadcrumb.module settings', ['module' => ucfirst($module)]) }}</li> <li class="active"><i class="fa fa-cog"></i> {{ trans('setting::settings.breadcrumb.module settings', ['module' => ucfirst($currentModule)]) }}</li>
</ol> </ol>
@stop @stop
...@@ -19,46 +19,61 @@ ...@@ -19,46 +19,61 @@
@include('flash::message') @include('flash::message')
{!! Form::open(['route' => ['dashboard.setting.store'], 'method' => 'post']) !!} {!! Form::open(['route' => ['dashboard.setting.store'], 'method' => 'post']) !!}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-2">
<div class="box box-info"> <div class="box box-info">
<div class="box-header"><h3 class="box-title">{{ trans('setting::settings.title.module settings') }}</h3></div>
<div class="box-body">
<ul>
<?php foreach($modulesWithSettings as $module => $settings): ?>
<li style="margin-bottom: 15px"><a href="{{ URL::route('dashboard.module.settings', [$module]) }}" class="btn btn-default btn-flat {{ $module == ucfirst($currentModule) ? 'disabled' : '' }}">{{ $module }}</a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<div class="col-md-10">
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">{{ trans('core::core.title.translatable fields') }}</h3>
</div>
<?php if ($translatableSettings): ?>
<div class="box-body"> <div class="box-body">
<div class="nav-tabs-custom"> <div class="nav-tabs-custom">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="{{ App::getLocale() == 'en' ? 'active' : '' }}"><a href="#tab_1-1" data-toggle="tab">{{ trans('core::core.tab.english') }}</a></li> <?php $i = 0; ?>
<li class="{{ App::getLocale() == 'fr' ? 'active' : '' }}"><a href="#tab_2-2" data-toggle="tab">{{ trans('core::core.tab.french') }}</a></li> <?php foreach(LaravelLocalization::getSupportedLocales() as $locale => $language): ?>
<?php $i++; ?>
<li class="{{ App::getLocale() == $locale ? 'active' : '' }}">
<a href="#tab_{{ $i }}" data-toggle="tab">{{ trans('core::core.tab.'. strtolower($language['name'])) }}</a>
</li>
<?php endforeach; ?>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane {{ App::getLocale() == 'en' ? 'active' : '' }}" id="tab_1-1"> <?php $i = 0; ?>
<?php foreach($moduleSettings as $settingName => $moduleInfo): ?> <?php foreach(LaravelLocalization::getSupportedLocales() as $locale => $language): ?>
@include($moduleInfo['view'], [ <?php $i++; ?>
'lang' => 'en', <div class="tab-pane {{ App::getLocale() == $locale ? 'active' : '' }}" id="tab_{{ $i }}">
'moduleSettings' => $moduleSettings, @include('setting::admin.partials.fields', ['settings' => $translatableSettings])
'settings' => $settings, </div>
'module' => $module, <?php endforeach; ?>
'setting' => $settingName,
'moduleInfo' => $moduleInfo,
])
<?php endforeach; ?>
</div>
<div class="tab-pane {{ App::getLocale() == 'fr' ? 'active' : '' }}" id="tab_2-2">
<?php foreach($moduleSettings as $settingName => $moduleInfo): ?>
@include($moduleInfo['view'], [
'lang' => 'fr',
'moduleSettings' => $moduleSettings,
'settings' => $settings,
'module' => $module,
'setting' => $settingName,
'moduleInfo' => $moduleInfo,
])
<?php endforeach; ?>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="box-footer"> <?php endif; ?>
<button type="submit" class="btn btn-primary btn-flat">{{ trans('core::core.button.create') }}</button> </div>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.setting.index')}}"><i class="fa fa-times"></i> {{ trans('core::core.button.cancel') }}</a> <?php if ($plainSettings): ?>
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">{{ trans('core::core.title.non translatable fields') }}</h3>
</div> </div>
<div class="box-body">
@include('setting::admin.partials.fields', ['settings' => $plainSettings])
</div>
</div>
<?php endif; ?>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('core::core.button.create') }}</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.setting.index')}}"><i class="fa fa-times"></i> {{ trans('core::core.button.cancel') }}</a>
</div> </div>
</div> </div>
</div> </div>
......
<div class='form-group{{ $errors->has("site-name[$lang]") ? ' has-error' : '' }}'> <?php use Illuminate\Support\Str; ?>
{!! Form::label("site-name[$lang]", 'Site name:') !!} <?php foreach($settings as $settingName => $moduleInfo): ?>
<?php if (isset($settings['site-name'])): ?> <?php $fieldView = Str::contains($moduleInfo['view'], '::') ? $moduleInfo['view'] : "setting::admin.fields.translatable.{$moduleInfo['view']}" ?>
{!! Form::text("site-name[$lang]", Input::old("site-name[$lang]", $settings['site-name']->translate($lang)->value), ['class' => 'form-control', 'placeholder' => 'Site name']) !!} @include($fieldView, [
<?php else: ?> 'lang' => $locale,
{!! Form::text("site-name[$lang]", Input::old("site-name[$lang]"), ['class' => 'form-control', 'placeholder' => 'Site name']) !!} 'settings' => $settings,
<?php endif; ?> 'setting' => $settingName,
{!! $errors->first("site-name[$lang]", '<span class="help-block">:message</span>') !!} 'moduleInfo' => $moduleInfo,
</div> ])
<div class='form-group{{ $errors->has("site-description[$lang]") ? ' has-error' : '' }}'> <?php endforeach;
{!! Form::label("site-description[$lang]", 'Site-description:') !!}
<?php if (isset($settings['site-description'])): ?>
{!! Form::textarea("site-description[$lang]", Input::old("site-description[$lang]", $settings['site-description']->translate($lang)->value), ['class' => 'form-control', 'placeholder' => 'Site description']) !!}
<?php else: ?>
{!! Form::textarea("site-description[$lang]", Input::old("site-description[$lang]"), ['class' => 'form-control', 'placeholder' => 'Site description']) !!}
<?php endif; ?>
{!! $errors->first("site-description[$lang]", '<span class="help-block">:message</span>') !!}
</div>
@extends('core::layouts.master')
@section('content-header')
<h1>
{{ trans('setting::settings.title.settings') }}
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> {{ trans('core::core.breadcrumb.home') }}</a></li>
<li class="active"><i class="fa fa-cog"></i> {{ trans('setting::settings.breadcrumb.settings') }}</li>
</ol>
@stop
@section('content')
@include('flash::message')
{!! Form::open(['route' => ['dashboard.setting.store'], 'method' => 'post']) !!}
<div class="row">
<div class="col-md-8">
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">{{ trans('setting::settings.title.general settings') }}</h3>
</div>
<div class="box-body">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="{{ App::getLocale() == 'en' ? 'active' : '' }}"><a href="#tab_1-1" data-toggle="tab">{{ trans('core::core.tab.english') }}</a></li>
<li class="{{ App::getLocale() == 'fr' ? 'active' : '' }}"><a href="#tab_2-2" data-toggle="tab">{{ trans('core::core.tab.french') }}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane {{ App::getLocale() == 'en' ? 'active' : '' }}" id="tab_1-1">
@include('setting::admin.partials.fields', ['lang' => 'en'])
</div>
<div class="tab-pane {{ App::getLocale() == 'fr' ? 'active' : '' }}" id="tab_2-2">
@include('setting::admin.partials.fields', ['lang' => 'fr'])
</div>
</div>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('core::core.button.create') }}</button>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box box-info">
<div class="box-header"><h3 class="box-title">{{ trans('setting::settings.title.module settings') }}</h3></div>
<div class="box-body">
<ul>
<?php foreach($modulesWithSettings as $module => $settings): ?>
<li><a href="{{ URL::route('dashboard.module.settings', [strtolower($module)]) }}">{{ $module }}</a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
@stop
<?php namespace Modules\Setting\Support;
use Modules\Core\Contracts\Setting;
use Modules\Setting\Repositories\SettingRepository;
class Settings implements Setting
{
/**
* @var SettingRepository
*/
private $setting;
/**
* @param SettingRepository $setting
*/
public function __construct(SettingRepository $setting)
{
$this->setting = $setting;
}
/**
* Getting the setting
* @param string $name
* @param null $locale
* @param null $default
* @return mixed
*/
public function get($name, $locale = null, $default = null)
{
$setting = $this->setting->get($name);
if ($setting) {
if ($setting->isTranslatable) {
return $setting->translate($locale)->value;
}
return $setting->plainValue;
}
return $default;
}
/**
* Determine if the given configuration value exists.
*
* @param string $name
* @return bool
*/
public function has($name)
{
$default = microtime(true);
return $this->get($name, null, $default) !== $default;
}
/**
* Set a given configuration value.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function set($key, $value)
{
}
}
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