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.


5 Replies
getTitle()
getTitle - returns the page title, not the full name of the component π

Solution
damn i needed to call a static method π

calling a static method didn't work outside the component. I had to do it like this:
$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
dd( "{$componentName}"); try this