Hessam
Issue with registerNavigationItems in Octane and RoadRunner
Hi everyone,
I’m encountering an issue when trying to display menu items based on user access in an Octane environment with RoadRunner. The problem arises only when using Octane, as everything works fine with a simple web server.
The core issue is that Octane boots once and does not clear variables between requests until the worker is reset. This behavior causes old navigation items to persist across requests, leading users to see unrelated menus from previous routes.
Here’s the relevant code from my provider:
Filament::serving(function (): void {
Filament::registerPanel(Filament::getCurrentPanel());
$menuItems = [......]
foreach ($menuItems as $menuItem) {
if ($menuItem->menu['showable']) {
Filament::registerNavigationItems([
NavigationItem::make($menuItem->menu['title'] ?? 'Default title')
->url(route('filament.manager.resources.contents.report', ['record' => $menuItem->slug]))
->group($menuItem->menu['navigation_group'] ?? 'Default group')
->sort(3),
]);
}
}
});
As you can see, on each request, I register navigation items based on the current user's access. However, when the page is refreshed, the user can see unrelated menus from previous routes because registerNavigationItems is not being cleared between requests.
I believe the issue lies in the navigationItems method in the NavigationManager class, where the items are just appended:
public function navigationItems(array $items): static
{
$this->navigationItems = [
...$this->navigationItems,
...$items,
];
return $this;
}
Would it be possible to clear the items and then fill them again on each request? Or do you have any ideas on how I can resolve or improve this approach to avoid displaying outdated navigation items?
Any advice would be greatly appreciated!
1 replies
Get extra parameters from URL for resources
Hello everyone
I have a nested resource.
In this way, I have a product resource that shows the list of products and I have made a list of attributes that shows the list of attribute according to the product ID, and you can also create or edit a new attribute for it.
And its url is as follows.
create url : /manager/product/attributes/{product}/create
edit url : /manager/product/attributes/{product}/{attribute}/edit
According to the product parameter in the url, I edited the getEloquent method and wrote it as follows.
public static function getTableQuery(): Builder
{
return parent::getEloquentQuery()
->where('attributeable_type', product()->model())
->where('attributeable_id', request('product'));
}
Now, when I add a delete action to the table, I get an error.
Because when removing the attribute, there is no product id parameter in the request.
This is because the deletion was done by the url related to livewire/update.
Keep this in mind, currently the creation and editing operation is working correctly as a page.
But there is an error in modal like the Delete operation.
Can someone tell me how I can keep this product parameter that is in the URL and use it in all situations?
2 replies