PHP code example of agroezinger / filament-navigation-enhanced
1. Go to this page and download the library: Download agroezinger/filament-navigation-enhanced library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
agroezinger / filament-navigation-enhanced example snippets
use Agroezinger\FilamentNavigationEnhanced\NavigationEnhancedPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
NavigationEnhancedPlugin::make(),
]);
}
use Agroezinger\FilamentNavigationEnhanced\NavigationEnhancedPlugin;
use Filament\Navigation\NavigationItem;
NavigationEnhancedPlugin::make()
->parentNavigationItem(
NavigationItem::make('Parent Menu Item')
->icon('heroicon-o-arrow-up-tray')
->group('Workflows')
->sort(10)
->childItems([
NavigationItem::make('Sub-Menu-Item 1')
->url(fn() => ImportOrderPositionsPage::getUrl())
->isActiveWhen(fn() => request()->routeIs('filament.frontend.pages.sub-menu-item-1*')),
NavigationItem::make('Sub-Menu-Item 2')
->url(fn() => ImportPricelistPage::getUrl())
->isActiveWhen(fn() => request()->routeIs('filament.frontend.pages.sub-menu-item-2*')),
])
)
protected static bool $shouldRegisterNavigation = false;
use Agroezinger\FilamentNavigationEnhanced\Concerns\HasNavigationChildren;
use Filament\Navigation\NavigationItem;
class SettingsPage extends Page
{
use HasNavigationChildren;
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-cog-6-tooth';
protected static string|\UnitEnum|null $navigationGroup = 'Einstellungen';
protected static ?string $navigationLabel = 'Einstellungen';
public static function getNavigationChildItems(): array
{
return [
NavigationItem::make('Allgemein')
->url(static::getUrl())
->icon('heroicon-o-cog-6-tooth')
->isActiveWhen(fn() => request()->routeIs('filament.club.pages.settings.general')),
NavigationItem::make('Abteilungen')
->url(DepartmentResource::getUrl('index'))
->icon('heroicon-o-rectangle-stack')
->isActiveWhen(fn() => request()->routeIs('filament.club.resources.departments.*')),
NavigationItem::make('Benutzer')
->url(UserResource::getUrl('index'))
->icon('heroicon-o-users')
->isActiveWhen(fn() => request()->routeIs('filament.club.resources.users.*')),
];
}
}
class DepartmentResource extends Resource
{
public static function shouldRegisterNavigation(): bool
{
return false;
}
}
protected static bool $shouldRegisterNavigation = false;
NavigationItem::make('Abteilungen')
->isActiveWhen(fn() => request()->routeIs('filament.{panel}.resources.{resource-slug}.*')),
NavigationItem::make('Allgemein')
->isActiveWhen(fn() => request()->routeIs('filament.{panel}.pages.{page-slug}')),
bash
php artisan vendor:publish --tag=navigation-enhanced-views
bash
php artisan route:list --name="filament.{panel}" --json \
| php -r "foreach(json_decode(file_get_contents('php://stdin'),true) as \$r) echo \$r['name'].PHP_EOL;"