added settings page in admin #93
This commit is contained in:
parent
fcec39fe0f
commit
4a1d7c59fb
@ -33,7 +33,7 @@ class CreateSettingsTable extends Migration
|
||||
[
|
||||
'order' => 1,
|
||||
'name' => 'Start Date',
|
||||
'group' => '',
|
||||
'group' => 'general',
|
||||
'key' => 'general.start_date',
|
||||
'value' => '',
|
||||
'type' => 'date',
|
||||
@ -45,7 +45,7 @@ class CreateSettingsTable extends Migration
|
||||
'group' => 'general',
|
||||
'key' => 'general.currency',
|
||||
'value' => 'dollar',
|
||||
'type' => 'text',
|
||||
'type' => 'select',
|
||||
'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble',
|
||||
'description' => 'Currency to show in the interface',
|
||||
],
|
||||
|
@ -2,42 +2,43 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Log;
|
||||
use Illuminate\Http\Request;
|
||||
use Setting;
|
||||
|
||||
use App\Models\Setting;
|
||||
|
||||
class SettingsController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Display a listing of setting.
|
||||
*
|
||||
* @return Response
|
||||
* Display the settings. Group them by the setting group
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
/*$settings = array_filter(Setting::all(), function ($key) {
|
||||
if (strpos($key, '_descrip') !== false) { return true; }
|
||||
return false;
|
||||
});*/
|
||||
$settings = [];
|
||||
$settings = Setting::orderBy('order', 'asc')->get();
|
||||
$settings = $settings->groupBy('group');
|
||||
|
||||
return view('admin.settings.index',[
|
||||
'settings' => $settings,
|
||||
'grouped_settings' => $settings,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified setting in storage.
|
||||
*
|
||||
* @param Setting $setting
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Setting $setting, Request $request)
|
||||
public function update(Request $request)
|
||||
{
|
||||
/*$this->validate($request, Setting::$rules, Setting::$messages);
|
||||
$this->updateEntry($setting, $request->all());*/
|
||||
foreach($request->post() as $id => $value) {
|
||||
$setting = Setting::find($id);
|
||||
if(!$setting) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Log::info('Updating "'.$setting->key.'" from "'.$setting->value.'" to "'.$value.'"');
|
||||
$setting->value = $value;
|
||||
$setting->save();
|
||||
}
|
||||
|
||||
flash('Settings saved!');
|
||||
return redirect('/admin/settings');
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,4 @@ class Setting extends BaseModel
|
||||
'description',
|
||||
];
|
||||
|
||||
public $casts = [
|
||||
'options' => 'array',
|
||||
];
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ Route::group([
|
||||
|
||||
# view/update settings
|
||||
Route::match(['get'], 'settings', 'SettingsController@index');
|
||||
Route::match(['post', 'put'], 'settings', 'SettingsController@update');
|
||||
Route::match(['post', 'put'], 'settings', 'SettingsController@update')->name('settings.update');
|
||||
|
||||
# pirep related routes
|
||||
Route::resource('pireps', 'PirepController');
|
||||
|
105
package-lock.json
generated
105
package-lock.json
generated
@ -243,6 +243,12 @@
|
||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
|
||||
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM="
|
||||
},
|
||||
"arrify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
|
||||
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
|
||||
"dev": true
|
||||
},
|
||||
"asn1": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
|
||||
@ -1189,11 +1195,6 @@
|
||||
"hoek": "2.16.3"
|
||||
}
|
||||
},
|
||||
"bootstrap-editable": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap-editable/-/bootstrap-editable-1.0.1.tgz",
|
||||
"integrity": "sha1-RFpnG1q1/td+jH9OX/vHlsYLUCM="
|
||||
},
|
||||
"bootstrap-sass": {
|
||||
"version": "3.3.7",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.3.7.tgz",
|
||||
@ -1860,6 +1861,67 @@
|
||||
"run-queue": "1.0.3"
|
||||
}
|
||||
},
|
||||
"copy-webpack-plugin": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.3.1.tgz",
|
||||
"integrity": "sha512-xlcFiW/U7KrpS6dFuWq3r8Wb7koJx7QVc7LDFCosqkikaVSxkaYOnwDLwilbjrszZ0LYZXThDAJKcQCSrvdShQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cacache": "10.0.1",
|
||||
"find-cache-dir": "1.0.0",
|
||||
"globby": "7.1.1",
|
||||
"is-glob": "4.0.0",
|
||||
"loader-utils": "0.2.17",
|
||||
"lodash": "4.17.4",
|
||||
"minimatch": "3.0.4",
|
||||
"p-limit": "1.1.0",
|
||||
"pify": "3.0.0",
|
||||
"serialize-javascript": "1.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"globby": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz",
|
||||
"integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"array-union": "1.0.2",
|
||||
"dir-glob": "2.0.0",
|
||||
"glob": "7.1.2",
|
||||
"ignore": "3.3.7",
|
||||
"pify": "3.0.0",
|
||||
"slash": "1.0.0"
|
||||
}
|
||||
},
|
||||
"is-extglob": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-glob": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz",
|
||||
"integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-extglob": "2.1.1"
|
||||
}
|
||||
},
|
||||
"loader-utils": {
|
||||
"version": "0.2.17",
|
||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz",
|
||||
"integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"big.js": "3.2.0",
|
||||
"emojis-list": "2.1.0",
|
||||
"json5": "0.5.1",
|
||||
"object-assign": "4.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"core-js": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz",
|
||||
@ -2540,6 +2602,27 @@
|
||||
"randombytes": "2.0.5"
|
||||
}
|
||||
},
|
||||
"dir-glob": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.0.0.tgz",
|
||||
"integrity": "sha512-37qirFDz8cA5fimp9feo43fSuRo2gHwaIn6dXL8Ber1dGwUosDrGZeCCXq57WnIqE4aQ+u3eQZzsk1yOzhdwag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arrify": "1.0.1",
|
||||
"path-type": "3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"path-type": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
|
||||
"integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pify": "3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dns-equal": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz",
|
||||
@ -4855,6 +4938,12 @@
|
||||
"resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz",
|
||||
"integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE="
|
||||
},
|
||||
"ignore": {
|
||||
"version": "3.3.7",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz",
|
||||
"integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==",
|
||||
"dev": true
|
||||
},
|
||||
"imagemin": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/imagemin/-/imagemin-5.3.1.tgz",
|
||||
@ -9421,6 +9510,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"serialize-javascript": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.4.0.tgz",
|
||||
"integrity": "sha1-fJWFFNtqwkQ6irwGLcn3iGp/YAU=",
|
||||
"dev": true
|
||||
},
|
||||
"serve-index": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz",
|
||||
|
@ -27,5 +27,8 @@
|
||||
"rivets": "0.9.6",
|
||||
"select2": "^4.0.5",
|
||||
"x-editable": "1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"copy-webpack-plugin": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
BIN
public/assets/admin/css/blue.png
Normal file
BIN
public/assets/admin/css/blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
public/assets/admin/css/blue@2x.png
Normal file
BIN
public/assets/admin/css/blue@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
58
public/assets/admin/css/vendor.min.css
vendored
58
public/assets/admin/css/vendor.min.css
vendored
@ -16363,57 +16363,63 @@ a.editable-click.editable-disabled:hover {
|
||||
border-right-color: #fff;
|
||||
}
|
||||
|
||||
/* iCheck plugin Flat skin, orange
|
||||
/* iCheck plugin Square skin, blue
|
||||
----------------------------------- */
|
||||
.icheckbox_flat-orange,
|
||||
.iradio_flat-orange {
|
||||
.icheckbox_square-blue,
|
||||
.iradio_square-blue {
|
||||
display: inline-block;
|
||||
*display: inline;
|
||||
vertical-align: middle;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: url(orange.png) no-repeat;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background: url(blue.png) no-repeat;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.icheckbox_flat-orange {
|
||||
.icheckbox_square-blue {
|
||||
background-position: 0 0;
|
||||
}
|
||||
.icheckbox_flat-orange.checked {
|
||||
background-position: -22px 0;
|
||||
.icheckbox_square-blue.hover {
|
||||
background-position: -24px 0;
|
||||
}
|
||||
.icheckbox_flat-orange.disabled {
|
||||
background-position: -44px 0;
|
||||
.icheckbox_square-blue.checked {
|
||||
background-position: -48px 0;
|
||||
}
|
||||
.icheckbox_square-blue.disabled {
|
||||
background-position: -72px 0;
|
||||
cursor: default;
|
||||
}
|
||||
.icheckbox_flat-orange.checked.disabled {
|
||||
background-position: -66px 0;
|
||||
.icheckbox_square-blue.checked.disabled {
|
||||
background-position: -96px 0;
|
||||
}
|
||||
|
||||
.iradio_flat-orange {
|
||||
background-position: -88px 0;
|
||||
.iradio_square-blue {
|
||||
background-position: -120px 0;
|
||||
}
|
||||
.iradio_flat-orange.checked {
|
||||
background-position: -110px 0;
|
||||
.iradio_square-blue.hover {
|
||||
background-position: -144px 0;
|
||||
}
|
||||
.iradio_flat-orange.disabled {
|
||||
background-position: -132px 0;
|
||||
.iradio_square-blue.checked {
|
||||
background-position: -168px 0;
|
||||
}
|
||||
.iradio_square-blue.disabled {
|
||||
background-position: -192px 0;
|
||||
cursor: default;
|
||||
}
|
||||
.iradio_flat-orange.checked.disabled {
|
||||
background-position: -154px 0;
|
||||
.iradio_square-blue.checked.disabled {
|
||||
background-position: -216px 0;
|
||||
}
|
||||
|
||||
/* HiDPI support */
|
||||
@media (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
|
||||
.icheckbox_flat-orange,
|
||||
.iradio_flat-orange {
|
||||
background-image: url(orange@2x.png);
|
||||
-webkit-background-size: 176px 22px;
|
||||
background-size: 176px 22px;
|
||||
.icheckbox_square-blue,
|
||||
.iradio_square-blue {
|
||||
background-image: url(blue@2x.png);
|
||||
-webkit-background-size: 240px 24px;
|
||||
background-size: 240px 24px;
|
||||
}
|
||||
}
|
||||
/*! X-editable - v1.5.1
|
||||
|
@ -1,8 +1,10 @@
|
||||
{
|
||||
"/assets/admin/vendor/paper-dashboard.css": "/assets/admin/vendor/paper-dashboard.css?id=729efec551211db36219",
|
||||
"/assets/frontend/css/now-ui-kit.css": "/assets/frontend/css/now-ui-kit.css?id=58ec3dc768f07fee143a",
|
||||
"/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=66957049f4a01c51c68d",
|
||||
"/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=f583577fe1de7a1da1e6",
|
||||
"/assets/admin/js/vendor.js": "/assets/admin/js/vendor.js?id=eb27f6c829378a084072",
|
||||
"/assets/admin/css/blue.png": "/assets/admin/css/blue.png?id=753a3c0dec86d3a38d9c",
|
||||
"/assets/admin/css/blue@2x.png": "/assets/admin/css/blue@2x.png?id=97da23d47b838cbd4bef",
|
||||
"/assets/system/js/vendor.js": "/assets/system/js/vendor.js?id=434db3f2c9beafd58bae",
|
||||
"/assets/system/css/vendor.css": "/assets/system/css/vendor.css?id=7bd98a28084fea99e307",
|
||||
"/assets/system/js/installer-vendor.js": "/assets/system/js/installer-vendor.js?id=b2bca761f222e97bf4ff"
|
||||
|
@ -140,8 +140,8 @@ $(document).ready(function () {
|
||||
$(".select2").select2();
|
||||
|
||||
$('input').iCheck({
|
||||
checkboxClass: 'icheckbox_flat-orange',
|
||||
radioClass: 'iradio_flat-orange'
|
||||
checkboxClass: 'icheckbox_square-blue',
|
||||
radioClass: 'icheckbox_square-blue'
|
||||
});
|
||||
|
||||
var storage = getStorage("phpvms.admin");
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
@section('title', 'Settings')
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@include('flash::message')
|
||||
@include('admin.settings.table')
|
||||
</div>
|
||||
@include('flash::message')
|
||||
@include('admin.settings.table')
|
||||
@endsection
|
||||
|
||||
@include('admin.settings.script')
|
||||
|
30
resources/views/admin/settings/script.blade.php
Normal file
30
resources/views/admin/settings/script.blade.php
Normal file
@ -0,0 +1,30 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#settings a').editable({
|
||||
type: 'text',
|
||||
mode: 'inline',
|
||||
emptytext: 'default',
|
||||
url: '/admin/settings/update',
|
||||
title: 'Enter override value',
|
||||
ajaxOptions: { 'type': 'put'},
|
||||
params: function(params) {
|
||||
return {
|
||||
fare_id: params.pk,
|
||||
name: params.name,
|
||||
value: params.value
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('submit', 'form.rm_fare', function(event) {
|
||||
event.preventDefault();
|
||||
$.pjax.submit(event, '#aircraft_fares_wrapper', {push: false});
|
||||
});
|
||||
|
||||
$(document).on('pjax:complete', function() {
|
||||
$(".select2").select2();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
@ -1,22 +1,44 @@
|
||||
<table class="table table-responsive" id="settings-table">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th>Description</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($settings as $s)
|
||||
<tr>
|
||||
<td>{!! $s->key !!}</td>
|
||||
<td>{!! $s->value !!}</td>
|
||||
<td>
|
||||
@if(Setting::get($s->key.'_descrip'))
|
||||
{!! Setting::get($s->key.'_descrip') !!}
|
||||
@else
|
||||
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
{!! Form::model($grouped_settings, ['route' => ['admin.settings.update'], 'method' => 'post']) !!}
|
||||
@foreach($grouped_settings as $group => $settings)
|
||||
<div class="card">
|
||||
<div class="content table-responsive table-full-width">
|
||||
<table class="table table-hover" id="flights-table">
|
||||
<thead>
|
||||
<th colspan="2">
|
||||
<h5>{!! $group !!}</h5>
|
||||
</th>
|
||||
</thead>
|
||||
|
||||
@foreach($settings as $setting)
|
||||
<tr>
|
||||
<td>
|
||||
<p>{!! $setting->name !!}</p>
|
||||
<p class="description">{{$setting->description}}</p></td>
|
||||
<td>
|
||||
@if($setting->type === 'text')
|
||||
{!! Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) !!}
|
||||
@elseif($setting->type === 'boolean' || $setting->type === 'bool')
|
||||
{!! Form::hidden($setting->id, 0) !!}
|
||||
{!! Form::checkbox($setting->id, null, $setting->value, ['']) !!}
|
||||
@elseif($setting->type === 'int' || $setting->type === 'number')
|
||||
{!! Form::number($setting->id, $setting->value, ['class'=>'form-control']) !!}
|
||||
@elseif($setting->type === 'select')
|
||||
{!! Form::select($setting->id,
|
||||
explode(',', $setting->options),
|
||||
$setting->value, ['class' => 'select2', 'style' => 'width: 100%']) !!}
|
||||
@else
|
||||
{!! Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) !!}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pull-right">
|
||||
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
|
||||
<a href="{!! route('admin.subfleets.index') !!}" class="btn btn-default">Cancel</a>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
|
@ -33,7 +33,7 @@ mix.styles([
|
||||
'public/assets/admin/vendor/font-awesome.css',
|
||||
'node_modules/select2/dist/css/select2.css',
|
||||
'node_modules/leaflet/dist/leaflet.css',
|
||||
'node_modules/icheck/skins/flat/orange.css',
|
||||
'node_modules/icheck/skins/square/blue.css',
|
||||
'node_modules/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css',
|
||||
'public/assets/admin/vendor/paper-dashboard.css',
|
||||
], 'public/assets/admin/css/vendor.min.css').version()
|
||||
@ -52,6 +52,8 @@ mix.scripts([
|
||||
'node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js',
|
||||
], 'public/assets/admin/js/vendor.js');
|
||||
|
||||
mix.copy('node_modules/icheck/skins/square/blue*.png', 'public/assets/admin/css');
|
||||
|
||||
/**
|
||||
* SYSTEM REQUIRED FILES
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user