F
Filamentβ€’3w ago
Tony

get resource page name

Hello how to get page component name? I need to get the component name elsewhere to use it to dispatch events to Livewire. Livewire.dispatchTo(componentName I tried to create an instance of an object, but there is no name.
No description
No description
No description
Solution:
damn i needed to call a static method πŸ˜…
No description
Jump to solution
5 Replies
jkbcoder
jkbcoderβ€’3w ago
getTitle()
Tony
TonyOPβ€’3w ago
getTitle - returns the page title, not the full name of the component 😞
No description
Solution
Tony
Tonyβ€’3w ago
damn i needed to call a static method πŸ˜…
No description
Tony
TonyOPβ€’3w ago
calling a static method didn't work outside the component. I had to do it like this:
Str::of(ListUsers::class)->kebab()->replace('\\-', '.')->toString()
Str::of(ListUsers::class)->kebab()->replace('\\-', '.')->toString()
jkbcoder
jkbcoderβ€’3w ago
$name = Str::replace('App\Livewire\', '', ListUsers::class); $name = Str::replace('\', '.', $name); $componentName = Str::afterLast($name, '.'); $componentName = Str::snake($componentName, '-'); $name = Str::beforeLast($name, '.'); $name = Str::lower($name); $name = Str::snake($name, '-');
dd( "{$componentName}"); try this

Did you find this page helpful?