feat: refine NavbarManager to restrict navigation modifications in admin context, enhance route handling, and improve icon validation, ensuring better separation of frontend and admin functionalities
This commit is contained in:
@@ -10,17 +10,44 @@ class ViewServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
// Register view namespace
|
||||
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'navbar-manager');
|
||||
// Load migrations from the extension so they run when the extension is enabled
|
||||
// Always load migrations regardless of context
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
|
||||
|
||||
// Register Blade components
|
||||
Blade::componentNamespace('Paymenter\\Extensions\\Others\\NavbarManager\\View\\Components', 'navbar-manager');
|
||||
|
||||
// Register global Blade directive for easy navbar usage
|
||||
Blade::directive('navbarManagerLinks', function ($expression) {
|
||||
return "<?php echo \Paymenter\Extensions\Others\NavbarManager\Helpers\NavbarHelper::render($expression); ?>";
|
||||
});
|
||||
// Only register views and components if not in admin context
|
||||
if (!$this->isAdminContext()) {
|
||||
// Register view namespace
|
||||
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'navbar-manager');
|
||||
|
||||
// Register Blade components
|
||||
Blade::componentNamespace('Paymenter\\Extensions\\Others\\NavbarManager\\View\\Components', 'navbar-manager');
|
||||
|
||||
// Register global Blade directive for easy navbar usage
|
||||
Blade::directive('navbarManagerLinks', function ($expression) {
|
||||
return "<?php echo \Paymenter\Extensions\Others\NavbarManager\Helpers\NavbarHelper::render($expression); ?>";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're in admin context
|
||||
*/
|
||||
private function isAdminContext(): bool
|
||||
{
|
||||
if (app()->runningInConsole()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$currentPath = request()->path();
|
||||
|
||||
return str_starts_with($currentPath, 'admin') ||
|
||||
str_contains($currentPath, '/admin/') ||
|
||||
str_starts_with($currentPath, 'filament') ||
|
||||
request()->is('admin') ||
|
||||
request()->is('admin/*') ||
|
||||
request()->is('filament/*');
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user