Created
July 12, 2024 05:28
-
-
Save neverything/6b7861a0fc313b22a2f5b2e249a2f405 to your computer and use it in GitHub Desktop.
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
<?php | |
use App\Filament\Resources\MilestoneResource; | |
use App\Filament\Resources\TaskResource; | |
use Filament\Navigation\NavigationBuilder; | |
use Filament\Navigation\NavigationGroup; | |
use Filament\Navigation\NavigationItem; | |
use Filament\Panel; | |
public function panel(Panel $panel): Panel | |
{ | |
return $panel | |
// ... | |
->navigation(function (NavigationBuilder $builder): NavigationBuilder { | |
$tenant = Filament::getTenant(); | |
// Provides the link for the tenant switch menu. | |
$builder->items([ | |
NavigationItem::make('Project Overview') | |
->icon('heroicon-o-home') | |
->url(fn () => route('filament.project.pages.dashboard', | |
['tenant' => $tenant])) | |
]); | |
// Only build the full navigation for the current tenant, otherwise you | |
// end up with extra queries if you want to display count badges. | |
if (auth()->user()->current_project_id === $tenant->id) { | |
$builder->groups([ | |
NavigationGroup::make($tenant->name) | |
->items([ | |
...TaskResource::getNavigationItems(), | |
...MilestoneResource::getNavigationItems(), | |
]), | |
]); | |
} | |
return $builder | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment