l5-repository icon indicating copy to clipboard operation
l5-repository copied to clipboard

How to custom generator

Open boyteenphonui opened this issue 6 years ago • 3 comments

I have many modules Module Article, Product, I use package https://github.com/nWidart/laravel-modules

How To generate everything by command artisan. For the module Article, Product ...

Thanks !

boyteenphonui avatar Apr 17 '18 16:04 boyteenphonui

Did you succeed? I would also like to use both together.

All advice is welcome here.

I'll keep you posted on my progress here.

pat-och avatar Aug 02 '18 14:08 pat-och

Any updates here?

osbre avatar Aug 03 '19 08:08 osbre

I also use both, to be able to use I created my own command to help me, but I have to keep migrating.

So I came in issues to make this request but the project is already quite crowded, I will continue migrating in the hand kkkk Detail if there are many people with this issue, I create a pull, to be able to solve the problem

namespace Modules\Sistema\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class CreateRepositoryCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'module:make-repository';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Criando repository';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        if(!\Module::has($this->argument('modulo'))):
            return $this->error('O modulo solicitado não foi localizado');
        endif;

        $basePath = \Module::find($this->argument('modulo'));

        \Config::set('repository.generator.basePath', $basePath->getPath());
        \Config::set('repository.generator.rootNamespace', "Modules\\{$basePath->getName()}\\");
        \Config::set('repository.generator.stubsOverridePath', $basePath->getPath());

        Artisan::call('make:repository', [
            'name' => $this->argument('repositorio')
        ]);

    }

    /**
     * Get the console command arguments.
     *
     * @return array
     */
    protected function getArguments()
    {
        return [
            ['repositorio', InputArgument::REQUIRED, 'Qual o repositorio que será criado'],
            ['modulo', InputArgument::REQUIRED, 'Em qual modulo será instalado'],
        ];
    }

    /**
     * Get the console command options.
     *
     * @return array
     */
    protected function getOptions()
    {
        return [];
    }
}

joaopaulopvillela avatar Feb 23 '21 15:02 joaopaulopvillela