laravel-generator icon indicating copy to clipboard operation
laravel-generator copied to clipboard

Allow add namespace to views

Open thewebartisan7 opened this issue 5 years ago • 1 comments
trafficstars

I wanted to generate all code inside a package and this work perfectly fine by just changing path and namespace in configuration of laravel_generator.php

However, the only things that can't be changed is view namespace.

With this change it's possible to add views prefix namespace, so that views are added and load from a package.

In config just add namespace prefix like so:

    'prefixes' => [
        'view' => 'mypackage::admin', 
    ],

Where mypackage is namespace when a new path is added from package using:

$this->loadViewsFrom(__DIR__.'/../resources/views', 'mypackage');

There should not be any BC, nor new configuration. Just a simple check if prefixes.view has "::" and if so storing namespace separately from view path.

Then in GeneratorConfig the dynamic variable $VIEW_PREFIX$ is replaced with namespace if set.

The same for ViewGenerator for selectTable fields.

I do test with several commands, but not sure if all cases are covered.

If I discover something else regarding generating code inside package, I will advise.

Of course is important to change also all laravel_generator.path and laravel_generator.namespace in config, especially the path.view.

Thanks for merging !

thewebartisan7 avatar Aug 26 '20 10:08 thewebartisan7

I have several other changes to handle this, in case you are interested, I can add here.

thewebartisan7 avatar Nov 20 '20 18:11 thewebartisan7