-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from MineTrax/feature/custom-navigation-maker
Feature: Custom Navbar Maker & Other Fixes
- Loading branch information
Showing
175 changed files
with
2,539 additions
and
1,676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
app/Http/Controllers/Admin/Settings/NavigationSettingController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin\Settings; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\CustomPage; | ||
use App\Settings\GeneralSettings; | ||
use App\Settings\NavigationSettings; | ||
use Illuminate\Http\Request; | ||
use Inertia\Inertia; | ||
|
||
class NavigationSettingController extends Controller | ||
{ | ||
public function __construct() | ||
{ | ||
$this->middleware(['can:update settings']); | ||
} | ||
|
||
public function show(NavigationSettings $settings, GeneralSettings $generalSettings) | ||
{ | ||
// Items which can be added to custom navbar | ||
$availableNavItems = config('minetrax.custom_nav_available_items_array'); | ||
|
||
// Custom pages which can be added | ||
$customPageItems = CustomPage::select(['id', 'title', 'path'])->get(); | ||
foreach ($customPageItems as $item) { | ||
$availableNavItems[] = [ | ||
'type' => 'custom-page', | ||
'name' => $item->title, | ||
'title' => $item->title, | ||
'id' => $item->id, | ||
'route' => 'custom-page.show', | ||
'route_params' => [ | ||
'path' => $item->path, | ||
], | ||
'key' => 'custom-page-' . $item->id, | ||
]; | ||
} | ||
|
||
return Inertia::render('Admin/Setting/NavigationSetting', [ | ||
'settings' => $settings->toArray(), | ||
'generalSettings' => $generalSettings->toArray(), | ||
'availableNavItems' => $availableNavItems, | ||
]); | ||
} | ||
|
||
public function update(Request $request, NavigationSettings $settings, GeneralSettings $generalSettings) | ||
{ | ||
$request->validate([ | ||
'enable_custom_navbar' => 'required|boolean', | ||
'custom_navbar_data' => 'nullable|array', | ||
'enable_sticky_header_menu' => 'required|boolean', | ||
]); | ||
|
||
$navbarData = $request->input('custom_navbar_data'); | ||
|
||
// Check in array if we have a dropdown type inside a dropdown type then we give error | ||
foreach ($navbarData as $sideList) { | ||
foreach ($sideList as $item) { | ||
if ($item['type'] === 'dropdown') { | ||
foreach ($item['children'] as $child) { | ||
if ($child['type'] === 'dropdown' || $child['type'] === 'component') { | ||
return redirect()->back() | ||
->with(['toast' => ['type' => 'error', 'title' => __('You can not add a dropdown or component inside of a dropdown')]]) | ||
->withErrors(['custom_navbar_data' => __('You can not add a dropdown or component inside of a dropdown')]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
$settings->enable_custom_navbar = $request->input('enable_custom_navbar'); | ||
$settings->custom_navbar_data = $navbarData; | ||
$settings->save(); | ||
|
||
$generalSettings->enable_sticky_header_menu = $request->input('enable_sticky_header_menu'); | ||
$generalSettings->save(); | ||
|
||
return redirect()->back() | ||
->with(['toast' => ['type' => 'success', 'title' => __('Navigation Settings Updated Successfully')]]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Settings; | ||
|
||
use Spatie\LaravelSettings\Settings; | ||
|
||
class NavigationSettings extends Settings | ||
{ | ||
public bool $enable_custom_navbar; | ||
public array $custom_navbar_data; | ||
|
||
public static function group(): string | ||
{ | ||
return 'navigation'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.