Skip to content

Commit

Permalink
Merge pull request #1422 from moonshine-software/make-resource-types
Browse files Browse the repository at this point in the history
feat: MakeResourceCommand with type option
  • Loading branch information
lee-to authored Dec 26, 2024
2 parents d296f41 + 0fbfb79 commit 7dccfa6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Laravel/src/Commands/MakeResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 7dccfa6

Please sign in to comment.