Access to route() in AppPanelProvider::panel()
Do we have access to routes in the
panel()
method before we do a call to $panel
?Solution:Jump to solution
Here is with closure. It works fine.
```php
MenuItem::make()
->url(function() {
return Account::getUrl();...
3 Replies
Route shouldn’t be an issue. But I guess you want to access filament routes? First: don’t use route. Use Resource::getUrl() method. Second. Put it in a closure do it’s evaluated later
I don't have only resources, for example I have a page and I'm trying to it's the URL with
route('filament.pages.account')
And the second problem is that I'm calling $panel->userMenuItems($userMenuItems)
and these menu items can't be set via closure so I have to define that $userMenuItems
before calling $panel
and within this defining I have to do something like MenuItem::make()->url(route('filament.pages.account'))
, so I can't use closure in any way for that.
Any other ideas how I can fix this?
Doing it with MenuItem::make()->url(Account::getUrl())
generates Call to a member function getId() on null
. I will try to pass that as closure...Solution
Here is with closure. It works fine.