F
Filament5mo ago
Vitor

Custom page before list resource

I need to add a custom page before listing a resource. I tried something like this:
public static function getPages(): array
{
return [
'index' => FactoriesListPage::route('/factories'),
'list' => ListProducts::route('/factory/{factory}'),
'create' => CreateProduct::route('/create'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
public static function getPages(): array
{
return [
'index' => FactoriesListPage::route('/factories'),
'list' => ListProducts::route('/factory/{factory}'),
'create' => CreateProduct::route('/create'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
I want a page to select a factory and, after a factory is selected, list the products where the factory matches the selected one. What is the best approach to this?
10 Replies
Dennis Koch
Dennis Koch5mo ago
When you say "before" you mean that this page should be in the navigation, right? You can overwrite the navigation by getNavigationItems() on the resource.
Vitor
VitorOP5mo ago
Thx for the reply, Dennis. It shouldn't be in the navigation. When clicking on the Products menu, I want to navigate to a custom page where a factory can be selected. After selecting a factory, I want to list all products that match the selected factory.
Dennis Koch
Dennis Koch5mo ago
Where is "Products menu" when it is not in the navigation?!
Vitor
VitorOP5mo ago
Basically, this is what i want:
Vitor
VitorOP5mo ago
No description
No description
Vitor
VitorOP5mo ago
Click on "Produtos" menu, go to a custom page to select the factory. After factory is selected, go to the matched list products table
LeandroFerreira
LeandroFerreira5mo ago
why not a factory filter in the list page?
Vitor
VitorOP5mo ago
The user has requested this custom page. And then, to create the product, I need to pass the same parameters from the selected factory so that the product is created based on it. I made this and it is working, but I’m not sure if it is the best way:
public static function getPages(): array
{
return [
'index' => FactoriesListPage::route('/factories'),
'list' => ListProducts::route('/factory/{factory}'),
'create' => CreateProduct::route('/create'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
public static function getPages(): array
{
return [
'index' => FactoriesListPage::route('/factories'),
'list' => ListProducts::route('/factory/{factory}'),
'create' => CreateProduct::route('/create'),
'edit' => EditProduct::route('/{record}/edit'),
];
}
Dennis Koch
Dennis Koch5mo ago
So you want to modify the navigation item?! That's exactly waht I explained
No description
Dennis Koch
Dennis Koch5mo ago
So that already worked? If it works that approach is fine 😅
Want results from more Discord servers?
Add your server