diff --git a/src/Pages/MenuPage.php b/src/Pages/MenuPage.php index 671cc8d..c62c8f5 100644 --- a/src/Pages/MenuPage.php +++ b/src/Pages/MenuPage.php @@ -118,13 +118,4 @@ public function getReports() return $reports; } - - // public function mount() - // { - // $reports = $this->getReports(); - // foreach ($reports as $key => $report) { - // $report = app($report); - // dd($report); - // } - // } } diff --git a/src/Report.php b/src/Report.php index 4d93dbb..d4bed18 100644 --- a/src/Report.php +++ b/src/Report.php @@ -38,7 +38,13 @@ class Report extends Page implements HasActionsPanel, HasBody, HasFooter, HasFor public ?string $logo = '/img/logo.png'; - public bool $shouldOpenInNewTab = false; + public bool $shouldOpenInNewTab = true; + + public int $sort = 0; + + public function getSort(): int { + return $this->sort; + } public function getShouldOpenInNewTab(): bool { diff --git a/src/ReportsPlugin.php b/src/ReportsPlugin.php index c5983cb..3ba536a 100644 --- a/src/ReportsPlugin.php +++ b/src/ReportsPlugin.php @@ -3,6 +3,7 @@ namespace EightyNine\Reports; use Filament\Contracts\Plugin; +use Filament\Navigation\NavigationGroup; use Filament\Navigation\NavigationItem; use Filament\Panel; use Filament\Support\Enums\MaxWidth; @@ -16,8 +17,6 @@ public function getId(): string public function register(Panel $panel): void { - - // register reports reports()->discoverReports( in: config('filament-reports.reports_directory'), for: config('filament-reports.reports_namespace') @@ -33,14 +32,27 @@ public function boot(Panel $panel): void { if (! reports()->getUseReportListPage()) { + // get reports with + $panel->navigationGroups([ + NavigationGroup::make() + ->label(reports()->getNavigationLabel() ?? __('filament-reports::menu-page.nav.group')) + ->icon(reports()->getNavigationIcon()), + ]); $panel->navigationItems(collect(reports()->getReports())->map(function ($report) { $report = app($report); - - return NavigationItem::make($report->getTitle()) + return NavigationItem::make($report->getHeading()) ->url(function () use ($report) { return $report->getUrl(); }) - ->group(reports()->getNavigationGroup() ?? __('filament-reports::menu-page.nav.group')); + ->parentItem(get_class($report)::getNavigationParentItem() ?? reports()->getNavigationParentItem()) + ->label(get_class($report)::getNavigationLabel() ?? $report->getHeading()) + ->sort(get_class($report)::getNavigationSort() ?? $report->getSort() ?? 0) + ->badge( + get_class($report)::getNavigationBadge(), + get_class($report)::getNavigationBadgeColor() + ) + ->icon(get_class($report)::getNavigationIcon() ?? $report->getIcon() ?? 'heroicon-o-document-text') + ->group(get_class($report)::getNavigationGroup() ?? reports()->getNavigationGroup() ?? __('filament-reports::menu-page.nav.group')); })->toArray()); } }