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

Config file doesn't work #27

Closed zloadmin closed 1 year ago

zloadmin commented 1 year ago

I have the module Dashboard in the folder Modules/Dashboard Config file in config/modules-livewire.php


<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Class Namespace
    |--------------------------------------------------------------------------
    |
    */

    'namespace' => '123Http\\Livewire',

    /*
    |--------------------------------------------------------------------------
    | View Path
    |--------------------------------------------------------------------------
    |
    */

    'view' => '123Modules/Dashboard/Resources/views/livewire',

    /*
    |--------------------------------------------------------------------------
    | Custom modules setup
    |--------------------------------------------------------------------------
    |
    */

     'custom_modules' => [
         'Dashboard' => [
             'path' => base_path('123Modules/Dashboard'),
             'module_namespace' => '123Libraries\\Dashboard',
              'namespace' => '123Http\\Livewire',
              'view' => '123Modules/Dashboard/Resources/views/livewire',
              'name_lower' => '123dashboard',
         ],
     ],

];

I cannot change the view folder. I added prefix 123 in config values but anyway I don't get error.

My route

Route::prefix('dashboard')->group(function() {
    Route::get('/users', \Modules\Dashboard\Http\Livewire\Pages\UserPage::class);
});

file resources/views/layouts/app.blade.php

<pre>
    {{ print_r(config('modules-livewire')) }}
</pre>
file resources/views/layouts/app.blade.php
{{ $slot }}

file Modules/Dashboard/Resources/views/livewire/pages/user-page.blade.php

<div>
    file Modules/Dashboard/Resources/views/livewire/pages/user-page.blade.php
</div>

What I got in page /dashboard/user

    Array
(
    [namespace] => 123Http\Livewire
    [view] => 123Modules/Dashboard/Resources/views/livewire
    [custom_modules] => Array
        (
            [Dashboard] => Array
                (
                    [path] => /Users/zloadmin/Projects/petapi/petapi/123Modules/Dashboard
                    [module_namespace] => 123Libraries\Dashboard
                    [namespace] => 123Http\Livewire
                    [view] => 123Modules/Dashboard/Resources/views/livewire
                    [name_lower] => 123dashboard
                )

        )

)
1
file resources/views/layouts/app.blade.php
file Modules/Dashboard/Resources/views/livewire/pages/user-page.blade.php

I tried with the default config, with custom_modules and without it, settings in the config file were ignored.

How to set a view folder for a specific module?

Thanks.

mhmiton commented 1 year ago

@zloadmin You can try these changes -

'view' => '123Modules/Dashboard/Resources/views/livewire',

to

'view' => 'Resources/views/livewire',

Please check on the example repository - https://github.com/mhmiton/laravel-modules-livewire-example

Ref: https://github.com/mhmiton/laravel-modules-livewire-example/blob/21ea08a2f43c67e673f88a7ee7b4927a5902e1a6/config/modules-livewire.php#L31