diff --git a/src/Laravel/src/Commands/MakeResourceCommand.php b/src/Laravel/src/Commands/MakeResourceCommand.php index 23fb46096..63fca6e57 100644 --- a/src/Laravel/src/Commands/MakeResourceCommand.php +++ b/src/Laravel/src/Commands/MakeResourceCommand.php @@ -13,7 +13,7 @@ #[AsCommand(name: 'moonshine:resource')] class MakeResourceCommand extends MoonShineCommand { - protected $signature = 'moonshine:resource {name?} {--m|model=} {--t|title=} {--test} {--pest}'; + protected $signature = 'moonshine:resource {name?} {--type=} {--m|model=} {--t|title=} {--test} {--pest}'; protected $description = 'Create resource'; @@ -41,11 +41,18 @@ public function handle(): int $this->makeDir($resourcesDir); - $stub = select('Resource type', [ + $types = [ 'ModelResourceDefault' => 'Default model resource', 'ModelResourceWithPages' => 'Model resource with pages', 'Resource' => 'Empty resource', - ], 'ModelResourceDefault'); + ]; + + if($type = $this->option('type')) { + $keys = array_keys($types); + $stub = $keys[$type-1] ?? $keys[0]; + } else { + $stub = select('Resource type', $types, 'ModelResourceDefault'); + } $replace = [ '{namespace}' => moonshineConfig()->getNamespace('\Resources'),