Commit d3b42637 authored by Nicolas Widart's avatar Nicolas Widart

Adding a settings edit page. Add setting repositories. Create new migration for transtaled settings

parent 6c3c2a4b
......@@ -10,7 +10,7 @@ class SidebarViewComposer
$view->items->put('setting', [
'weight' => 5,
'request' => "*/$view->prefix/settings",
'route' => 'dashboard.settings',
'route' => 'dashboard.setting.index',
'icon-class' => 'fa fa-cog',
'title' => 'Settings',
]);
......
......@@ -14,9 +14,6 @@ class CreateSettingsTable extends Migration
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('value');
$table->text('description');
$table->timestamps();
});
}
......
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSettingTranslationsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('setting_translations', function(Blueprint $table)
{
$table->increments('id');
$table->integer('setting_id')->unsigned();
$table->string('locale')->index();
$table->string('name');
$table->string('value');
$table->text('description');
$table->unique(['setting_id','locale']);
$table->foreign('setting_id')->references('id')->on('settings')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('setting_translations');
}
}
<?php namespace Modules\Setting\Entities;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
}
\ No newline at end of file
<?php namespace Modules\Setting\Http\Controllers;
<?php namespace Modules\Setting\Http\Controllers\Admin;
use Illuminate\Support\Facades\View;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Setting\Repositories\SettingRepository;
class SettingController extends AdminBaseController
{
/**
* @var SettingRepository
*/
private $setting;
public function __construct(SettingRepository $setting)
{
parent::__construct();
$this->setting = $setting;
}
public function index()
{
return View::make('setting::admin.settings');
}
public function store()
{
}
}
\ No newline at end of file
......@@ -3,6 +3,13 @@
Route::group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin'], function() {
Route::group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Setting\Http\Controllers'], function()
{
Route::get('settings', ['as' => 'dashboard.settings','uses' => 'SettingController@index']);
Route::resource('settings', 'Admin\SettingController', ['except' => ['show'], 'names' => [
'index' => 'dashboard.setting.index',
'create' => 'dashboard.setting.create',
'store' => 'dashboard.setting.store',
'edit' => 'dashboard.setting.edit',
'update' => 'dashboard.setting.update',
'destroy' => 'dashboard.setting.destroy',
]]);
});
});
<?php namespace Modules\Setting\Providers;
use Illuminate\Support\ServiceProvider;
use Modules\Setting\Entities\Setting;
use Modules\Setting\Repositories\Eloquent\EloquentSettingRepository;
class SettingServiceProvider extends ServiceProvider {
......@@ -18,7 +20,9 @@ class SettingServiceProvider extends ServiceProvider {
*/
public function register()
{
//
$this->app->booted(function ($app) {
$this->registerBindings();
});
}
/**
......@@ -31,4 +35,13 @@ class SettingServiceProvider extends ServiceProvider {
return array();
}
private function registerBindings()
{
$this->app->bind(
'Modules\Setting\Repositories\SettingRepository',
function() {
return new EloquentSettingRepository(new Setting);
}
);
}
}
<?php namespace Modules\Setting\Repositories\Eloquent;
use Modules\Core\Repositories\Eloquent\EloquentBaseRepository;
use Modules\Setting\Repositories\SettingRepository;
class EloquentSettingRepository extends EloquentBaseRepository implements SettingRepository
{
/**
* Update a resource
* @param $id
* @param $data
* @return mixed
*/
public function update($id, $data)
{
}
public function create($data)
{
}
}
\ No newline at end of file
<?php namespace Modules\Setting\Repositories;
use Modules\Core\Repositories\BaseRepository;
interface SettingRepository extends BaseRepository
{
}
\ No newline at end of file
<div class='form-group{{ $errors->has("site-name[$lang]") ? ' has-error' : '' }}'>
{!! Form::label("site-name[$lang]", 'Site name:') !!}
{!! Form::text("site-name[$lang]", Input::old("site-name[$lang]"), ['class' => 'form-control', 'placeholder' => 'Site name']) !!}
{!! $errors->first("site-name[$lang]", '<span class="help-block">:message</span>') !!}
</div>
<div class='form-group{{ $errors->has("site-description[$lang]") ? ' has-error' : '' }}'>
{!! Form::label("site-description[$lang]", 'Site-description:') !!}
{!! Form::textarea("site-description[$lang]", Input::old("site-description[$lang]"), ['class' => 'form-control', 'placeholder' => 'Site description']) !!}
{!! $errors->first("site-description[$lang]", '<span class="help-block">:message</span>') !!}
</div>
\ No newline at end of file
......@@ -10,9 +10,46 @@
@stop
@section('content')
@include('flash::message')
{!! Form::open(['route' => ['dashboard.setting.store'], 'method' => 'post']) !!}
<div class="row">
<div class="col-md-12">
<p>Settings</p>
<div class="col-md-8">
<div class="box box-info">
<div class="box-header">
<h3 class="box-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 active" id="tab_1-1">
@include('setting::admin.partials.fields', ['lang' => 'en'])
</div>
<div class="tab-pane" 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('user::button.create') }}</button>
<a class="btn btn-danger pull-right btn-flat" href="{{ URL::route('dashboard.user.index')}}"><i class="fa fa-times"></i> {{ trans('user::button.cancel') }}</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box box-info">
<div class="box-header"><h3 class="box-title">Module Settings</h3></div>
<div class="box-body">
<ul>
<li><a href="">Module 1</a></li>
</ul>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
@stop
\ No newline at end of file
......@@ -5,5 +5,8 @@
"keywords": [
],
"active": 1
"active": 1,
"providers": [
"Modules\\Setting\\Providers\\SettingServiceProvider"
]
}
\ No newline at end of file
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