Skip to content

Commit

Permalink
Merge pull request #2811 from joy2fun/patch-2
Browse files Browse the repository at this point in the history
Added an option to custom the controller stub
  • Loading branch information
z-song committed Dec 3, 2018
2 parents 000e08e + ff5fb16 commit 08abf47
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Console/MakeCommand.php
Expand Up @@ -12,7 +12,10 @@ class MakeCommand extends GeneratorCommand
*
* @var string
*/
protected $signature = 'admin:make {name} {--model=} {--O|output}';
protected $signature = 'admin:make {name}
{--model=}
{--stub= : Path to the custom stub file. }
{--O|output}';

/**
* The console command description.
Expand All @@ -39,6 +42,14 @@ public function handle()
return false;
}

$stub = $this->option('stub');

if ($stub and !is_file($stub)) {
$this->error('The stub file dose not exist.');

return false;
}

$modelName = $this->option('model');

$this->generator = new ResourceGenerator($modelName);
Expand Down Expand Up @@ -128,6 +139,10 @@ protected function indentCodes($code)
*/
protected function getStub()
{
if ($stub = $this->option('stub')) {
return $stub;
}

if ($this->option('model')) {
return __DIR__.'/stubs/controller.stub';
}
Expand Down

0 comments on commit 08abf47

Please sign in to comment.