359 Select theme in settings (#423)
* Update composer package versions * Laravel version * Change theme in the admin settings page closes #359 * Fix comment
This commit is contained in:
parent
eff9f6fec6
commit
ec4f10d43a
4
Makefile
4
Makefile
@ -65,7 +65,9 @@ reset: clean
|
|||||||
|
|
||||||
.PHONY: reload-db
|
.PHONY: reload-db
|
||||||
reload-db:
|
reload-db:
|
||||||
@php artisan phpvms:dev-install --reset-db
|
@php artisan database:create --reset
|
||||||
|
@php artisan migrate --seed
|
||||||
|
@echo "Done!"
|
||||||
@make clean
|
@make clean
|
||||||
|
|
||||||
.PHONY: tests
|
.PHONY: tests
|
||||||
|
@ -13,14 +13,6 @@ class DevInstall extends Command
|
|||||||
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
|
protected $signature = 'phpvms:dev-install {--reset-db} {--reset-configs}';
|
||||||
protected $description = 'Run a developer install and run the sample migration';
|
protected $description = 'Run a developer install and run the sample migration';
|
||||||
|
|
||||||
/**
|
|
||||||
* The YAML files with sample data to import
|
|
||||||
*/
|
|
||||||
protected $yaml_imports = [
|
|
||||||
'sample.yml',
|
|
||||||
'acars.yml',
|
|
||||||
];
|
|
||||||
|
|
||||||
private $databaseSeeder;
|
private $databaseSeeder;
|
||||||
|
|
||||||
public function __construct(\DatabaseSeeder $databaseSeeder)
|
public function __construct(\DatabaseSeeder $databaseSeeder)
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
- key: general.theme
|
||||||
|
name: 'Current Theme'
|
||||||
|
group: general
|
||||||
|
value: 'default'
|
||||||
|
options: ''
|
||||||
|
type: select
|
||||||
|
description: 'The currently active theme'
|
||||||
- key: general.start_date
|
- key: general.start_date
|
||||||
name: 'Start Date'
|
name: 'Start Date'
|
||||||
group: general
|
group: general
|
||||||
|
@ -4,14 +4,34 @@ namespace App\Http\Controllers\Admin;
|
|||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
use Igaster\LaravelTheme\Facades\Theme;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SettingsController
|
* Class SettingsController
|
||||||
*/
|
*/
|
||||||
class SettingsController extends Controller
|
class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get a list of themes formatted for a select box
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getThemes(): array
|
||||||
|
{
|
||||||
|
$themes = Theme::all();
|
||||||
|
$theme_list = [];
|
||||||
|
foreach ($themes as $t) {
|
||||||
|
if (!$t || !$t->name || $t->name === 'false') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$theme_list[] = $t->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $theme_list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the settings. Group them by the setting group
|
* Display the settings. Group them by the setting group
|
||||||
*/
|
*/
|
||||||
@ -22,6 +42,7 @@ class SettingsController extends Controller
|
|||||||
|
|
||||||
return view('admin.settings.index', [
|
return view('admin.settings.index', [
|
||||||
'grouped_settings' => $settings,
|
'grouped_settings' => $settings,
|
||||||
|
'themes' => $this->getThemes(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
app/Http/Middleware/SetActiveTheme.php
Normal file
22
app/Http/Middleware/SetActiveTheme.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Igaster\LaravelTheme\Facades\Theme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the current theme from the settings (set in admin), and set it
|
||||||
|
*/
|
||||||
|
class SetActiveTheme
|
||||||
|
{
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
$theme = setting('general.theme');
|
||||||
|
if (!empty($theme)) {
|
||||||
|
Theme::set($theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,11 @@
|
|||||||
/**
|
/**
|
||||||
* User doesn't need to be logged in for these
|
* User doesn't need to be logged in for these
|
||||||
*/
|
*/
|
||||||
|
use App\Http\Middleware\SetActiveTheme;
|
||||||
|
|
||||||
Route::group([
|
Route::group([
|
||||||
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.',
|
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.',
|
||||||
|
'middleware' => [SetActiveTheme::class],
|
||||||
], function () {
|
], function () {
|
||||||
Route::get('/', 'HomeController@index')->name('home');
|
Route::get('/', 'HomeController@index')->name('home');
|
||||||
Route::get('r/{id}', 'PirepController@show')->name('pirep.show.public');
|
Route::get('r/{id}', 'PirepController@show')->name('pirep.show.public');
|
||||||
@ -21,7 +24,7 @@ Route::group([
|
|||||||
*/
|
*/
|
||||||
Route::group([
|
Route::group([
|
||||||
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.',
|
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.',
|
||||||
'middleware' => ['role:admin|user'],
|
'middleware' => ['role:admin|user', SetActiveTheme::class],
|
||||||
], function () {
|
], function () {
|
||||||
Route::resource('dashboard', 'DashboardController');
|
Route::resource('dashboard', 'DashboardController');
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"ext-simplexml": "*",
|
"ext-simplexml": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"composer/composer": "~1.8.0",
|
"composer/composer": "~1.8.0",
|
||||||
"laravel/framework": "~6.0.0",
|
"laravel/framework": "~6.0",
|
||||||
"akaunting/money": "^1.0",
|
"akaunting/money": "^1.0",
|
||||||
"anhskohbo/no-captcha": "^3.0",
|
"anhskohbo/no-captcha": "^3.0",
|
||||||
"appstract/laravel-opcache": "^2.0",
|
"appstract/laravel-opcache": "^2.0",
|
||||||
|
539
composer.lock
generated
539
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -31,17 +31,6 @@ return [
|
|||||||
'currency' => 'USD',
|
'currency' => 'USD',
|
||||||
],
|
],
|
||||||
|
|
||||||
// This is the name of the active theme
|
|
||||||
// Overrides config/themes.php
|
|
||||||
'themes' => [
|
|
||||||
'default' => 'default',
|
|
||||||
],
|
|
||||||
|
|
||||||
// Overrides config/vacentral.php
|
|
||||||
'vacentral' => [
|
|
||||||
'api_key' => '',
|
|
||||||
],
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Other settings and configuration you might not need to modify
|
// Other settings and configuration you might not need to modify
|
||||||
//
|
//
|
||||||
|
@ -29,11 +29,20 @@
|
|||||||
@elseif($setting->type === 'number')
|
@elseif($setting->type === 'number')
|
||||||
{{ Form::number($setting->id, $setting->value, ['class'=>'form-control', 'step' => '0.01']) }}
|
{{ Form::number($setting->id, $setting->value, ['class'=>'form-control', 'step' => '0.01']) }}
|
||||||
@elseif($setting->type === 'select')
|
@elseif($setting->type === 'select')
|
||||||
|
|
||||||
|
@if($setting->id === 'general_theme')
|
||||||
|
{{ Form::select(
|
||||||
|
$setting->id,
|
||||||
|
list_to_assoc($themes),
|
||||||
|
$setting->value,
|
||||||
|
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
|
||||||
|
@else
|
||||||
{{ Form::select(
|
{{ Form::select(
|
||||||
$setting->id,
|
$setting->id,
|
||||||
list_to_assoc(explode(',', $setting->options)),
|
list_to_assoc(explode(',', $setting->options)),
|
||||||
$setting->value,
|
$setting->value,
|
||||||
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
|
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
|
||||||
|
@endif
|
||||||
@else
|
@else
|
||||||
{{ Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) }}
|
{{ Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) }}
|
||||||
@endif
|
@endif
|
||||||
@ -55,9 +64,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ Form::close() }}
|
{{ Form::close() }}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#datepicker').datetimepicker({
|
$('#datepicker').datetimepicker({
|
||||||
format: "YYYY-MM-DD"
|
format: "YYYY-MM-DD"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user