Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple namespaces #22

Closed
Surt opened this issue Mar 9, 2020 · 7 comments
Closed

Multiple namespaces #22

Surt opened this issue Mar 9, 2020 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@Surt
Copy link

Surt commented Mar 9, 2020

Hello,

eager to try the package.
Actually I have multiple namespaces and can't make schematics to read them. I need to set the config for each individual package. Since some packages make use of others I can't make them appear on the interface.

Can I trick schematics to scaffold a "base" namespace, so it finds the "models" in there?

Edited: The config only affects new models forms etc... the scaffolding is not working right now.

I'm using https://github.com/nWidart/laravel-modules, nothing fancy, just a way to divide the code into components, 100% laravel way. But still...

@Surt
Copy link
Author

Surt commented Mar 9, 2020

Found it:
vendor/mtolhuys/laravel-schematics/src/Services/ModelMapper.php
on the function map, line 23 it uses app_path(). Could it be changed to a "config" optional parameter? Setting that to my route works like a charm.

@mtolhuys
Copy link
Owner

mtolhuys commented Mar 9, 2020

Hi @Surt !

Yeah, I could take this with me in the next release. Just to be clear: do you just want the path to be configurable pointing to another f.e. base_path('foo')? Or have an array of paths that then need to be combined in the mapping process?

@mtolhuys mtolhuys added this to the 0.10.0 milestone Mar 9, 2020
@mtolhuys mtolhuys added enhancement New feature or request good first issue Good for newcomers labels Mar 9, 2020
@SlyDave
Copy link

SlyDave commented Mar 9, 2020

Array of paths please, so it mimics composer's autoload PSR-4 mapping.

I suffer the same issue as OP, that it's only loading in models in the App\ namespace even if I change the model-namespace configuration. - which makes for a rather empty schematic on our setup 😢

(otherwise, this is a pretty freaking awesome package! kudos)

@mtolhuys
Copy link
Owner

mtolhuys commented Mar 9, 2020

Thanks @SlyDave!

Working on the array of paths, coming soon!

@mtolhuys
Copy link
Owner

@Surt @SlyDave

you could try it out in 0.10.0.

config now:

'model' => [
    'namespace' => 'App\\',
    'paths' => [
        app_path(), \\ Add any path you want the mapper to scan
    ],
],

@SlyDave
Copy link

SlyDave commented Mar 11, 2020

Works great! - Thanks :)

'model' => [
        'namespace' => 'App\\',
        'paths' => [
            app_path(),
            base_path('MyModels')
        ],
    ],

(obviously replace "MyModels" with your models directory; don't call your models folder MyModels ;P)

@Surt
Copy link
Author

Surt commented Mar 12, 2020

Yeah! Works great! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants