Browse Source

feat: ✨ Added auto list item generation -> based on files in tabs directory

IceToast 3 years ago
parent
commit
267f28e6e9

+ 8 - 7
app/Http/Controllers/Admin/SettingsControllers/SettingsController.php

@@ -26,18 +26,19 @@ class SettingsController extends Controller
             $tabs[] = 'admin.settings.tabs.' . basename($filename, '.blade.php');
         }
 
-        // <li class="nav-item">
-        //     <a class="nav-link" data-toggle="pill" href="#invoice">{{ __('Invoice Settings2') }}</a>
-        // </li>
-
-        //Generate a html list item for each tab based on tabs file basename
-        $tabsListItem = [];
+        //Generate a html list item for each tab based on tabs file basename, set first tab as active
+        $tabListItems = [];
         foreach ($tabs as $tab) {
-            $tabsListItem[] = '<li class="nav-item"><a class="nav-link" href="' . route('admin.settings.index', ['tab' => $tab]) . '">' . str_replace('_', ' ', ucfirst(basename($tab, '.blade.php'))) . '</a></li>';
+            $tabName = str_replace('admin.settings.tabs.', '', $tab);
+            $tabListItems[] = '<li class="nav-item">
+            <a class="nav-link ' . (empty($tabListItems) ? 'active' : '') . '" data-toggle="pill" href="#' . $tabName . '">
+            ' . __(ucfirst($tabName)) . '
+            </a></li>';
         }
 
         return view('admin.settings.index', [
             'tabs' => $tabs,
+            'tabListItems' => $tabListItems,
         ]);;
     }
 

+ 1 - 1
package-lock.json

@@ -1,5 +1,5 @@
 {
-    "name": "bitsec-dashboard",
+    "name": "controllpanelgg",
     "lockfileVersion": 2,
     "requires": true,
     "packages": {

+ 4 - 57
resources/views/admin/settings/index.blade.php

@@ -36,67 +36,14 @@
 
                     <!-- Nav pills -->
                     <ul class="nav nav-tabs">
-                        <li class="nav-item">
-                            <a class="nav-link active" data-toggle="pill"
-                                href="#dashboard-icons">{{ __('Dashboard icons') }}</a>
-                        </li>
-                        <li class="nav-item">
-                            <a class="nav-link" data-toggle="pill"
-                                href="#invoice-settings">{{ __('Invoice Settings') }}</a>
-                        </li>
-                        <li class="nav-item">
-                            <a class="nav-link" data-toggle="pill" href="#invoice">{{ __('Invoice Settings2') }}</a>
-                        </li>
+
+                        @foreach ($tabListItems as $tabListItem)
+                            {!! $tabListItem !!}
+                        @endforeach
                     </ul>
 
                     <!-- Tab panes -->
                     <div class="tab-content">
-                        <div class="tab-pane mt-3 active" id="dashboard-icons">
-
-                            <form method="POST" enctype="multipart/form-data" class="mb-3"
-                                action="{{ route('admin.settings.update.icons') }}">
-                                @csrf
-                                @method('PATCH')
-
-                                <div class="row">
-                                    <div class="col-md-6 col-lg-4 col-12">
-                                        <div class="form-group">
-                                            <div class="custom-file mb-3 mt-3">
-                                                <input type="file" accept="image/png,image/jpeg,image/jpg"
-                                                    class="custom-file-input" name="icon" id="icon">
-                                                <label class="custom-file-label selected"
-                                                    for="icon">{{ __('Select panel icon') }}</label>
-                                            </div>
-                                            @error('icon')
-                                                <span class="text-danger">
-                                                    {{ $message }}
-                                                </span>
-                                            @enderror
-                                        </div>
-                                        <div class="form-group">
-                                            <div class="custom-file mb-3">
-                                                <input type="file" accept="image/x-icon" class="custom-file-input"
-                                                    name="favicon" id="favicon">
-                                                <label class="custom-file-label selected"
-                                                    for="favicon">{{ __('Select panel favicon') }}</label>
-                                            </div>
-                                            @error('favicon')
-                                                <span class="text-danger">
-                                                    {{ $message }}
-                                                </span>
-                                            @enderror
-                                        </div>
-                                    </div>
-                                </div>
-
-                                <button class="btn btn-primary">{{ __('Submit') }}</button>
-                            </form>
-
-                            <p class="text-muted">Images and Icons may be cached, use <code>CNTRL +
-                                    F5</code><sup>(google
-                                    chrome hotkey)</sup> to reload without cache to see your changes appear :)</p>
-
-                        </div>
 
                         @foreach ($tabs as $tab)
                             @include($tab)

+ 43 - 0
resources/views/admin/settings/tabs/dashboard.blade.php

@@ -0,0 +1,43 @@
+<div class="tab-pane mt-3 active" id="dashboard">
+    <form method="POST" enctype="multipart/form-data" class="mb-3"
+        action="{{ route('admin.settings.update.icons') }}">
+        @csrf
+        @method('PATCH')
+
+        <div class="row">
+            <div class="col-md-6 col-lg-4 col-12">
+                <div class="form-group">
+                    <div class="custom-file mb-3 mt-3">
+                        <input type="file" accept="image/png,image/jpeg,image/jpg" class="custom-file-input" name="icon"
+                            id="icon">
+                        <label class="custom-file-label selected" for="icon">{{ __('Select panel icon') }}</label>
+                    </div>
+                    @error('icon')
+                        <span class="text-danger">
+                            {{ $message }}
+                        </span>
+                    @enderror
+                </div>
+                <div class="form-group">
+                    <div class="custom-file mb-3">
+                        <input type="file" accept="image/x-icon" class="custom-file-input" name="favicon" id="favicon">
+                        <label class="custom-file-label selected"
+                            for="favicon">{{ __('Select panel favicon') }}</label>
+                    </div>
+                    @error('favicon')
+                        <span class="text-danger">
+                            {{ $message }}
+                        </span>
+                    @enderror
+                </div>
+            </div>
+        </div>
+
+        <button class="btn btn-primary">{{ __('Submit') }}</button>
+    </form>
+
+    <p class="text-muted">Images and Icons may be cached, use <code>CNTRL +
+            F5</code><sup>(google
+            chrome hotkey)</sup> to reload without cache to see your changes appear :)</p>
+
+</div>

+ 3 - 1
resources/views/admin/settings/tabs/invoice.blade.php

@@ -1,3 +1,5 @@
+@inject('Invoices', 'App\Http\Controllers\Admin\SettingsControllers\InvoiceSettingsController')
+
 <div class="tab-pane mt-3" id="invoice">
     <div class="float-right">
         <a href="{{ route('admin.settings.downloadAllInvoices') }}"><button
@@ -15,7 +17,7 @@
                     <div class="custom-control mb-3">
                         <label for="company-name">{{ __('Enter your companys name') }}</label>
                         <input x-model="company-name" id="company-name" name="company-name" type="text"
-                            value="{{ $invoiceSettings->company_name }}"
+                            value="{{ $Invoices->invoiceSettings->company_name }}"
                             class="form-control @error('company-name') is-invalid @enderror">
                     </div>
                 </div>