diff --git a/app/Http/Controllers/Admin/UsefulLinkController.php b/app/Http/Controllers/Admin/UsefulLinkController.php index ea51c37d..df66e834 100644 --- a/app/Http/Controllers/Admin/UsefulLinkController.php +++ b/app/Http/Controllers/Admin/UsefulLinkController.php @@ -48,7 +48,14 @@ class UsefulLinkController extends Controller '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!')); } @@ -93,7 +100,13 @@ class UsefulLinkController extends Controller '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!')); } diff --git a/app/Models/UsefulLink.php b/app/Models/UsefulLink.php index 4d788e0d..d040eadd 100644 --- a/app/Models/UsefulLink.php +++ b/app/Models/UsefulLink.php @@ -16,5 +16,6 @@ class UsefulLink extends Model 'title', 'link', 'description', + 'navbar', ]; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index e9390b6e..40aa0b29 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use App\Models\Settings; +use App\Models\UsefulLink; use Exception; use Illuminate\Pagination\Paginator; use Illuminate\Support\Facades\Artisan; @@ -53,6 +54,12 @@ class AppServiceProvider extends ServiceProvider 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 try { $settings = Settings::all(); diff --git a/database/migrations/2023_01_25_204343_useful_links_on_top_navbar.php b/database/migrations/2023_01_25_204343_useful_links_on_top_navbar.php new file mode 100644 index 00000000..46c3b027 --- /dev/null +++ b/database/migrations/2023_01_25_204343_useful_links_on_top_navbar.php @@ -0,0 +1,32 @@ +string('navbar')->after("description")->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('useful_links', function (Blueprint $table) { + $table->dropColumn('navbar'); + }); + } +}; diff --git a/themes/default/views/admin/usefullinks/create.blade.php b/themes/default/views/admin/usefullinks/create.blade.php index 53f68509..dd1b2824 100644 --- a/themes/default/views/admin/usefullinks/create.blade.php +++ b/themes/default/views/admin/usefullinks/create.blade.php @@ -94,6 +94,21 @@ @enderror +