Target Class [cache] does not exist
I don't really know much about the core behaviour and what todo/not todo inside service providers
What i am attempting to create is a simple session based "recently viewed" list of navigation items in the sidebar utilizing
\Filament\Navigation\NavigationItem::make()
on items visited
See attached image
Any panel requirements of core laravel features doesn't seem to work, like translations ( using a __('text')
anywhere in labels doesn't resolve the translation and only results in a "Target Class [translator] does not exist"
results in a Illuminate\Contracts\Container\BindingResolutionException
Target class [cache] does not exist.
My providers array looks like this: ( config/app.php
)
Is this intended behaviour of the panel service provider?
Is it bad practice to use dynamic features in this way? not sure where to move the logic to get the same benefits
Next option on my todo list is to move the Navigation items into a Page and use the getNavigationItems
method to resolve it (https://filamentphp.com/docs/3.x/panels/navigation#registering-custom-navigation-items-1)4 Replies
I was able to move my logic into a Page
Although now the page is responsible for the entire "recently viewed" section of the navigation
I added my logic to a Custom page and overwrote the:
getNavigationItems
function
I kept the original Page NavigationItem and just added my own array afterwards
Still need to clean it up abit, but no missing Cache class anymore 😛
The issue was, that the method was probably executed through a service provider and the framework wasn’t booted yet
Wondering how we can "fix" this the correct way
I don't mind having the logic moved, but it seems like a bug not being able to do translations in a service provider when the panel's configuration is being set there
Moving stuff in a closure instead of executing it directly in the method should be a solution