mhmiton / laravel-modules-livewire

Using Laravel Livewire in Laravel Modules package with automatically registered livewire components for every modules.
MIT License
187 stars 34 forks source link

Component not found in Livewire's post update method #39

Closed jorgeluiz1586 closed 9 months ago

jorgeluiz1586 commented 9 months ago

I set up my Laravel application to work by modules, I created the first module which is the Dashboard module and in it there are components in /modules/Dashboard/app/Livewire/Pages

The system works until I use wire:click to update a property in the component, it simply results in an error with status 500 in the post type route in localhost:8000/livewire/update it says the following:

Captura de tela de 2024-02-20 22-11-18

I tested with components outside the Dashboard module and the update works, but in the module it gives an error.

mhmiton commented 9 months ago

@jorgeluiz1586 Did you configure the livewire namespace path on the config file for - /modules/Dashboard/app/Livewire?

By default the namespace will be used - /modules/Dashboard/Livewire.

jorgeluiz1586 commented 9 months ago

Yes, I configured the namespace in composer.json, so much so that it only gives an error when the Livewire update route is executed.

I'll set up this default namespace to see if it works

jorgeluiz1586 commented 9 months ago

I managed to solve the problem, in the Livewire\Mechanisms\ComponentRegistry file on line 115 a wrong Namespace is checked, it joins the base name space with that of the module, so App\Livewire\Modules\Dashboard\App\Livewire\Pages\Instances\Index I fixed it by making a command in Artisan that replaces this file with a similar file with a treatment to check if it's a Livewire component class from a module or from the root when it's from a module I delete App\Livewire and the Index end of the wrong namespace App\Livewire\Modules\Dashboard\App\Livewire\Pages\Instances\Index and it's working, I'll finish this conversation, thank you very much for your attention