Skip to content

Commit

Permalink
boots filament navigation page options
Browse files Browse the repository at this point in the history
  • Loading branch information
eighty9nine committed Jul 27, 2024
1 parent 6e6da6b commit f911a4b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
9 changes: 0 additions & 9 deletions src/Pages/MenuPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// }
// }
}
8 changes: 7 additions & 1 deletion src/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 17 additions & 5 deletions src/ReportsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')
Expand All @@ -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());
}
}
Expand Down

0 comments on commit f911a4b

Please sign in to comment.