Method Illuminate\Support\Str::ucwords does not exist.

I am trying to add navigation groups (as shown in the docs: https://filamentphp.com/docs/3.x/panels/navigation#registering-custom-navigation-groups). This is a new Laravel v11 project (with Filament v3). Instead of a custom navigation group, I get an error about a missing method on the Str class: https://flareapp.io/share/oPRryqAP Is this something I need to create a reproduction repo for, or does someone have an idea about what I'm doing wrong>
20 Replies
assertchris
assertchris2mo ago
This method doesn't appear to exist in the docs or api documentation.
Povilas K
Povilas K2mo ago
https://laravel.com/docs/11.x/strings#available-methods it doesn't exist indeed, method title() is preferred. Where does that ucwords come from? You're saying it's from Filament internals?
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Povilas K
Povilas K2mo ago
Hmmm, could be a Filament bug indeed, then. I've checked a few older Laravel versions and seems like this method never existed. It should be PHP ucwords() instead, as one of the options.
Dennis Koch
Dennis Koch2mo ago
The method is macroed just some lines before this. Are you running some code before the ServiceProvider is ran? https://github.com/filamentphp/filament/blob/e5a4893b98ce1d22a6bc83544b25e5ac94af7117/packages/support/src/SupportServiceProvider.php#L129-L134
GitHub
filament/packages/support/src/SupportServiceProvider.php at e5a4893...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
assertchris
assertchris2mo ago
I see that macro now. I am running the same code as in the docs. I've shared it here: https://gist.github.com/assertchris/5e7a52f3430070583d29e5b08afae0d4
Dennis Koch
Dennis Koch2mo ago
Put your navigation items into a closure. Otherwise they are evaluated on the spot before the app is booted
assertchris
assertchris2mo ago
navigationItems is type-hinted as an array as is the nested items function how?
Dennis Koch
Dennis Koch2mo ago
Then you need to use the ->navigation method and provide the full builder Or does NavigationGroup::make()->items() accept a Closure?
assertchris
assertchris2mo ago
ok, that sounds like an option. when I did that, previously, it wiped out all the existing navigation. is there a way to appends only? NavigationGroup::make()->items() does not only array
Dennis Koch
Dennis Koch2mo ago
I don't think so
assertchris
assertchris2mo ago
so I can have a custom navigation group or the navigation filament builds, but not both?
Dennis Koch
Dennis Koch2mo ago
Why do you register that manually anyway?
NavigationGroup::make('Resume')
->items([
...EmploymentRoleResource::getNavigationItems(),
]),
NavigationGroup::make('Resume')
->items([
...EmploymentRoleResource::getNavigationItems(),
]),
assertchris
assertchris2mo ago
I want to have custom pages and links grouped with that resource management that was just the minimum amount of code required to trigger the error
Dennis Koch
Dennis Koch2mo ago
Custom pages shouldn't be an issue. But I don't know a better way for custom links, sorry. Wait, maybe I know. Try overriding getNavigationItems() of your resource. Use the default and add your custom links
assertchris
assertchris2mo ago
ok, cool, thanks will try that marking this as resolved because I would rather just honestly do whatever is possible (even without routing) than try to debug this further 🙂 but thank you for the help Following up on this, it's much easier to use protected static ?string $navigationGroup = 'Documents'; in the places where you can. Not always possible (say, if you're adding a new item via provider), but custom pages and resources group effortlessly via this approach.
Dennis Koch
Dennis Koch2mo ago
Sure. But I thought you wanted custom links to external pages which wouldn’t work that way
assertchris
assertchris2mo ago
I managed to package the custom link functionality as an action on one of the custom pages
Shavik
Shavik5w ago
@assertchris I'm running into this as well. I feel like I'm doing it just as the docs say but get that Str::ucwords exception like you were getting. Hmm I see, that was on navigationGroups which doesn't accept a closure. Now building full manual with the builder and it loads.
Dennis Koch
Dennis Koch5w ago
Hmm I see, that was on navigationGroups which doesn't accept a closure
I guess that makes sense, since the method is macroed in a ServiceProvider.