diff --git a/app/Enums/UsefulLinkLocation.php b/app/Enums/UsefulLinkLocation.php new file mode 100644 index 00000000..b43162ba --- /dev/null +++ b/app/Enums/UsefulLinkLocation.php @@ -0,0 +1,19 @@ +with('positions', $positions); } /** @@ -48,7 +50,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, + 'position' => implode(",",$request->position), + ]); return redirect()->route('admin.usefullinks.index')->with('success', __('link has been created!')); } @@ -72,8 +81,10 @@ class UsefulLinkController extends Controller */ public function edit(UsefulLink $usefullink) { + $positions = UsefulLinkLocation::cases(); return view('admin.usefullinks.edit', [ 'link' => $usefullink, + 'positions' => $positions, ]); } @@ -93,7 +104,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, + 'position' => implode(",",$request->position), + ]); return redirect()->route('admin.usefullinks.index')->with('success', __('link has been updated!')); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index ce72d947..23b41bb0 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -111,7 +111,7 @@ class HomeController extends Controller return view('home')->with([ 'usage' => $usage, 'credits' => $credits, - 'useful_links' => UsefulLink::all()->sortBy('id'), + 'useful_links' => UsefulLink::where("position","like","%dashboard%")->get()->sortby("id"), 'bg' => $bg, 'boxText' => $boxText, 'unit' => $unit, diff --git a/app/Models/UsefulLink.php b/app/Models/UsefulLink.php index 4d788e0d..c54f3d26 100644 --- a/app/Models/UsefulLink.php +++ b/app/Models/UsefulLink.php @@ -16,5 +16,6 @@ class UsefulLink extends Model 'title', 'link', 'description', + 'position', ]; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index e9390b6e..6da0675a 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', 'position')) { + $useful_links = UsefulLink::where("position","like","%topbar%")->get()->sortby("id"); + 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..cfaacf35 --- /dev/null +++ b/database/migrations/2023_01_25_204343_useful_links_on_top_navbar.php @@ -0,0 +1,32 @@ +string('position')->after("description")->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('useful_links', function (Blueprint $table) { + $table->dropColumn('position'); + }); + } +}; diff --git a/themes/default/views/admin/settings/tabs/system.blade.php b/themes/default/views/admin/settings/tabs/system.blade.php index a49c4d0a..4ac14cf6 100644 --- a/themes/default/views/admin/settings/tabs/system.blade.php +++ b/themes/default/views/admin/settings/tabs/system.blade.php @@ -481,7 +481,7 @@ - diff --git a/themes/default/views/admin/usefullinks/create.blade.php b/themes/default/views/admin/usefullinks/create.blade.php index 53f68509..b7174657 100644 --- a/themes/default/views/admin/usefullinks/create.blade.php +++ b/themes/default/views/admin/usefullinks/create.blade.php @@ -94,6 +94,22 @@ @enderror +