Browse Source

Useful Links in Topbar

1day2die 2 years ago
parent
commit
f923eef868

+ 15 - 2
app/Http/Controllers/Admin/UsefulLinkController.php

@@ -48,7 +48,14 @@ class UsefulLinkController extends Controller
             'description' => 'required|string|max:2000',
             'description' => 'required|string|max:2000',
         ]);
         ]);
 
 
-        UsefulLink::create($request->all());
+
+        UsefulLink::create([
+            'icon' => $request->icon,
+            'title' => $request->title,
+            'link' => $request->link,
+            'description' => $request->description,
+            'navbar' => $request->navbar,
+        ]);
 
 
         return redirect()->route('admin.usefullinks.index')->with('success', __('link has been created!'));
         return redirect()->route('admin.usefullinks.index')->with('success', __('link has been created!'));
     }
     }
@@ -93,7 +100,13 @@ class UsefulLinkController extends Controller
             'description' => 'required|string|max:2000',
             'description' => 'required|string|max:2000',
         ]);
         ]);
 
 
-        $usefullink->update($request->all());
+        $usefullink->update([
+            'icon' => $request->icon,
+            'title' => $request->title,
+            'link' => $request->link,
+            'description' => $request->description,
+            'navbar' => $request->navbar,
+        ]);
 
 
         return redirect()->route('admin.usefullinks.index')->with('success', __('link has been updated!'));
         return redirect()->route('admin.usefullinks.index')->with('success', __('link has been updated!'));
     }
     }

+ 1 - 0
app/Models/UsefulLink.php

@@ -16,5 +16,6 @@ class UsefulLink extends Model
         'title',
         'title',
         'link',
         'link',
         'description',
         'description',
+        'navbar',
     ];
     ];
 }
 }

+ 7 - 0
app/Providers/AppServiceProvider.php

@@ -3,6 +3,7 @@
 namespace App\Providers;
 namespace App\Providers;
 
 
 use App\Models\Settings;
 use App\Models\Settings;
+use App\Models\UsefulLink;
 use Exception;
 use Exception;
 use Illuminate\Pagination\Paginator;
 use Illuminate\Pagination\Paginator;
 use Illuminate\Support\Facades\Artisan;
 use Illuminate\Support\Facades\Artisan;
@@ -53,6 +54,12 @@ class AppServiceProvider extends ServiceProvider
             return $ok;
             return $ok;
         });
         });
 
 
+
+        if (Schema::hasColumn('useful_links', 'navbar')) {
+            $useful_links = UsefulLink::where("navbar", "true")->get();
+            view()->share('useful_links', $useful_links);
+        }
+
         //only run if the installer has been executed
         //only run if the installer has been executed
         try {
         try {
             $settings = Settings::all();
             $settings = Settings::all();

+ 32 - 0
database/migrations/2023_01_25_204343_useful_links_on_top_navbar.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('useful_links', function (Blueprint $table) {
+            $table->string('navbar')->after("description")->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('useful_links', function (Blueprint $table) {
+            $table->dropColumn('navbar');
+        });
+    }
+};

+ 15 - 0
themes/default/views/admin/usefullinks/create.blade.php

@@ -94,6 +94,21 @@
                                     @enderror
                                     @enderror
                                 </div>
                                 </div>
 
 
+                                <div class="form-group">
+                                    <div class="col m-0 p-0 d-flex justify-content-between align-items-center">
+                                        <div>
+                                            <input value="true" id="navbar" name="navbar"
+                                                   type="checkbox">
+                                            <label for="navbar">{{ __('Show link on top Navbar') }} </label>
+                                        </div>
+                                    </div>
+                                    @error('navbar')
+                                    <div class="text-danger">
+                                        {{$message}}
+                                    </div>
+                                    @enderror
+                                </div>
+
 
 
                                 <div class="form-group text-right">
                                 <div class="form-group text-right">
                                     <button type="submit" class="btn btn-primary">
                                     <button type="submit" class="btn btn-primary">

+ 15 - 0
themes/default/views/admin/usefullinks/edit.blade.php

@@ -95,6 +95,21 @@
                                     @enderror
                                     @enderror
                                 </div>
                                 </div>
 
 
+                                <div class="form-group">
+                                    <div class="col m-0 p-0 d-flex justify-content-between align-items-center">
+                                        <div>
+                                            <input value="true" id="navbar" name="navbar"
+                                                   type="checkbox" @if($link->navbar == "true") checked @endif
+                                            <label for="navbar">{{ __('Show link on top Navbar') }} </label>
+                                        </div>
+                                    </div>
+                                    @error('navbar')
+                                    <div class="text-danger">
+                                        {{$message}}
+                                    </div>
+                                    @enderror
+                                </div>
+
 
 
                                 <div class="form-group text-right">
                                 <div class="form-group text-right">
                                     <button type="submit" class="btn btn-primary">
                                     <button type="submit" class="btn btn-primary">

+ 2 - 0
themes/default/views/admin/usefullinks/index.blade.php

@@ -41,6 +41,7 @@
                             <th width="50">{{__('Icon')}}</th>
                             <th width="50">{{__('Icon')}}</th>
                             <th>{{__('Title')}}</th>
                             <th>{{__('Title')}}</th>
                             <th>{{__('Link')}}</th>
                             <th>{{__('Link')}}</th>
+                            <th>{{__('Navbar')}}</th>
                             <th>{{__('Created at')}}</th>
                             <th>{{__('Created at')}}</th>
                             <th></th>
                             <th></th>
                         </tr>
                         </tr>
@@ -79,6 +80,7 @@
                     {data: 'icon'},
                     {data: 'icon'},
                     {data: 'title'},
                     {data: 'title'},
                     {data: 'link'},
                     {data: 'link'},
+                    {data: 'navbar'},
                     {data: 'created_at'},
                     {data: 'created_at'},
                     {data: 'actions', sortable: false},
                     {data: 'actions', sortable: false},
                 ],
                 ],

+ 7 - 2
themes/default/views/layouts/main.blade.php

@@ -22,8 +22,6 @@
     {{-- summernote --}}
     {{-- summernote --}}
     <link rel="stylesheet" href="{{ asset('plugins/summernote/summernote-bs4.min.css') }}">
     <link rel="stylesheet" href="{{ asset('plugins/summernote/summernote-bs4.min.css') }}">
 
 
-
-
     {{-- datetimepicker --}}
     {{-- datetimepicker --}}
     <link rel="stylesheet"
     <link rel="stylesheet"
         href="{{ asset('plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css') }}">
         href="{{ asset('plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css') }}">
@@ -62,6 +60,13 @@
                                 class="fab fa-discord mr-2"></i>{{ __('Discord') }}</a>
                                 class="fab fa-discord mr-2"></i>{{ __('Discord') }}</a>
                     </li>
                     </li>
                 @endif
                 @endif
+
+                @foreach($useful_links as $link)
+                    <li class="nav-item d-none d-sm-inline-block">
+                        <a href="{{ $link->link }}" class="nav-link" target="__blank"><i
+                                class="{{$link->icon}}"></i> {{ $link->title }}</a>
+                    </li>
+                @endforeach
                 <!-- Language Selection -->
                 <!-- Language Selection -->
                 @if (config('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') == 'true')
                 @if (config('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') == 'true')
                     <li class="nav-item dropdown">
                     <li class="nav-item dropdown">