F
Filament7mo ago
Pscl

Dashboard in SubNavigation

In my Resource I am trying to do setup a subNavigation with a Dashboard Item that gives me a link to a dashboard just for the record.

//Resource
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\Dashboard::class,
]);
}

public static function getPages(): array
{
return [
'dashboard' => Pages\Dashboard::route('/{record}/dashboard'),
];
}

//Page/Dashboard
class Dashboard extends BaseDashboard

//Resource
public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
Pages\Dashboard::class,
]);
}

public static function getPages(): array
{
return [
'dashboard' => Pages\Dashboard::route('/{record}/dashboard'),
];
}

//Page/Dashboard
class Dashboard extends BaseDashboard
The error I get
Method App\Filament\Resources\ModelResource\Pages\Dashboard::route does not exist.
Method App\Filament\Resources\ModelResource\Pages\Dashboard::route does not exist.
Ofcourse... but any Idea how to get it working to utilize Dashboard as a SubNavigation Page for a specific record?
16 Replies
John Wink
John Wink7mo ago
Is this page registered in the Panel Provider?
Pscl
PsclOP7mo ago
@CyQuer Yes.
Vp
Vp7mo ago
Does it works if you don't extend BaseDashboard?
Pscl
PsclOP7mo ago
@Vp No. Because route() is not available here:
public static function getPages(): array
{
return [
'dashboard' => Pages\Dashboard::route('/{record}/dashboard'),
];
}
public static function getPages(): array
{
return [
'dashboard' => Pages\Dashboard::route('/{record}/dashboard'),
];
}
In my Resource file. Route is only available if I extend the Dashboard class with ViewRecord or so. But not with Page oder BaseDashboard.
Pscl
PsclOP7mo ago
This works. But now how to add dashboard functionality to this page?
Vp
Vp7mo ago
What kind of dashboard functionality? it is a custom page, you can add widgets (https://filamentphp.com/docs/3.x/panels/pages#adding-widgets-to-pages) or table or form etc https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component https://filamentphp.com/docs/3.x/tables/adding-a-table-to-a-livewire-component If you want filter (like dashboard) that I don't know
Pscl
PsclOP7mo ago
Yes, this was one idea to utilize this filterForm on this page.
Vp
Vp7mo ago
I think you can create your own filter (not sure how to do it) and apply on widgets https://filamentphp.com/docs/3.x/panels/pages#passing-data-to-widgets-from-the-page
Pscl
PsclOP7mo ago
Ok. Thank you for your help. Maybe someone else will come up with an idea 🙂
Vp
Vp7mo ago
https://demo.filamentphp.com/shop/orders take a look at this, displaying widgets like this is also nice, it changes based on table filter also (not what you want exactly but for reference 😆 )
Pscl
PsclOP7mo ago
Yes, this doesn't help me :/
Vp
Vp7mo ago
This is how you create custom filter
protected function getHeaderActions(): array
{
return [
Action::make('filter')
->iconButton()
->icon('heroicon-m-funnel')
->slideOver()
->form([
DatePicker::make('date_of_birth'),
])
->action(function (array $data): void {
dd($data);
})
->modalWidth(MaxWidth::Small),
];
}
protected function getHeaderActions(): array
{
return [
Action::make('filter')
->iconButton()
->icon('heroicon-m-funnel')
->slideOver()
->form([
DatePicker::make('date_of_birth'),
])
->action(function (array $data): void {
dd($data);
})
->modalWidth(MaxWidth::Small),
];
}
And accept the data like this and filter the widgets https://filamentphp.com/docs/3.x/panels/pages#passing-properties-to-widgets-on-pages
Vp
Vp7mo ago
Pscl
PsclOP7mo ago
@Vp thanks! I will dig into your idea. Really appreciate your help.
Want results from more Discord servers?
Add your server