From e9fec445ff9e73170826616592aee727ebbd63cd Mon Sep 17 00:00:00 2001 From: IceToast Date: Thu, 9 Feb 2023 18:29:03 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Send=20all=20settings=20in?= =?UTF-8?q?=20their=20groups=20to=20frontend=20->=20show=20tabs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/SettingsController.php | 31 ++--- .../views/admin/settings/index.blade.php | 126 +++++------------- 2 files changed, 42 insertions(+), 115 deletions(-) diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 75165696..f9ef3380 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -18,33 +18,24 @@ class SettingsController extends Controller */ public function index() { - //Get all tabs as laravel view paths - $tabs = []; - if(file_exists(Theme::getViewPaths()[0] . '/admin/settings/tabs/')){ - $tabspath = glob(Theme::getViewPaths()[0] . '/admin/settings/tabs/*.blade.php'); - }else{ - $tabspath = glob(Theme::path('views', 'default').'/admin/settings/tabs/*.blade.php'); - } - foreach ($tabspath as $filename) { - $tabs[] = 'admin.settings.tabs.'.basename($filename, '.blade.php'); + // get all other settings in app/Settings directory + // group items by file name like $categories + $settings = collect(); + foreach (scandir(app_path('Settings')) as $file) { + if (in_array($file, ['.', '..'])) { + continue; + } + $className = 'App\\Settings\\' . str_replace('.php', '', $file); + $settings[str_replace('Settings.php', '', $file)] = (new $className())->toCollection()->all(); } + $settings->sort(); - //Generate a html list item for each tab based on tabs file basename, set first tab as active - $tabListItems = []; - foreach ($tabs as $tab) { - $tabName = str_replace('admin.settings.tabs.', '', $tab); - $tabListItems[] = ''; - } $themes = array_diff(scandir(base_path('themes')), array('..', '.')); return view('admin.settings.index', [ - 'tabs' => $tabs, - 'tabListItems' => $tabListItems, + 'settings' => $settings->all(), 'themes' => $themes, 'active_theme' => Theme::active(), ]); diff --git a/themes/default/views/admin/settings/index.blade.php b/themes/default/views/admin/settings/index.blade.php index 231870e2..47589f35 100644 --- a/themes/default/views/admin/settings/index.blade.php +++ b/themes/default/views/admin/settings/index.blade.php @@ -19,11 +19,12 @@ - @if(!file_exists(base_path()."/install.lock")) + @if (!file_exists(base_path() . '/install.lock'))

{{ __('The installer is not locked!') }}

-

{{ __('please create a file called "install.lock" in your dashboard Root directory. Otherwise no settings will be loaded!') }}

- +

{{ __('please create a file called "install.lock" in your dashboard Root directory. Otherwise no settings will be loaded!') }} +

+
@endif @@ -37,98 +38,35 @@
- + + + + +
+ + @foreach ($settings as $key => $value) + < + + @endforeach + +
- - @@ -159,6 +97,4 @@ $('html,body').scrollTop(scrollmem); }); - - @endsection