joserick / laravel-livewire-discover

Automatically discover and load/register multiple/different class namespaces for Livewire components.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request - Resolve Nested Namespaces

Fludem opened this issue · comments

Hey,

I believe having the package resolve nested namespaces automatically would be a good feature.

For example:

So take a component in the namespace:

namespace ClockingSystems\Auth\Livewire\Pages;

Then in the config file we'll define this:

'class_namespaces' => [
        'clocking-systems.auth' => 'ClockingSystems\\Auth\\Livewire',
    ],

This will give this error when using a full page component:

Unable to find component: [clocking-systems.auth-login]

Changing the namespace to include the pages namespace will allow it to work:

'class_namespaces' => [
        'clocking-systems.auth' => 'ClockingSystems\\Auth\\Livewire\\Pages',
    ],

I believe it should work like this

'class_namespaces' => [
        'clocking-systems.auth' => 'ClockingSystems\\Auth\\Livewire',
    ],

Which allows use of components in nested namespaces such as

<livewire:clocking-systems.auth.pages.login/>
<livewire:clocking-systems.auth.modals.forgot-password/>

This is how the livewire component discovery works by default

Hi,

Sorry for the delay, I finally had some free time of "life" and "work" :(

I've made the necessary corrections and posted the new version v1.0.0

Unfortunately, compatibility with previous versions has been broken, so a migration is necessary migration-to-v1