diff --git a/src/Generator/Commands/ContainerApiGenerator.php b/src/Generator/Commands/ContainerApiGenerator.php index 90a3fddd..2e206fac 100644 --- a/src/Generator/Commands/ContainerApiGenerator.php +++ b/src/Generator/Commands/ContainerApiGenerator.php @@ -336,6 +336,7 @@ public function getUserInputs(): array|null '--section' => $sectionName, '--container' => $containerName, '--file' => $route['controller'], + '--model' => $model, '--ui' => $ui, '--stub' => $route['stub'], ]); @@ -360,6 +361,7 @@ public function getUserInputs(): array|null $this->call('apiato:generate:controller', [ '--section' => $sectionName, '--container' => $containerName, + '--model' => $model, '--file' => 'Controller', '--ui' => $ui, '--stub' => 'crud', diff --git a/src/Generator/Commands/ContainerWebGenerator.php b/src/Generator/Commands/ContainerWebGenerator.php index 86d27d7e..c8b8077b 100644 --- a/src/Generator/Commands/ContainerWebGenerator.php +++ b/src/Generator/Commands/ContainerWebGenerator.php @@ -251,6 +251,7 @@ public function getUserInputs(): array|null '--section' => $sectionName, '--container' => $containerName, '--file' => $route['controller'], + '--model' => $model, '--ui' => $ui, '--stub' => $route['stub'], ]); @@ -276,6 +277,7 @@ public function getUserInputs(): array|null '--section' => $sectionName, '--container' => $containerName, '--file' => 'Controller', + '--model' => $model, '--ui' => $ui, '--stub' => 'crud', ]); diff --git a/src/Generator/Commands/ControllerGenerator.php b/src/Generator/Commands/ControllerGenerator.php index 63907d65..6098c65c 100644 --- a/src/Generator/Commands/ControllerGenerator.php +++ b/src/Generator/Commands/ControllerGenerator.php @@ -18,6 +18,7 @@ class ControllerGenerator extends GeneratorCommand implements ComponentsGenerato public array $inputs = [ ['ui', null, InputOption::VALUE_OPTIONAL, 'The user-interface to generate the Controller for.'], ['stub', null, InputOption::VALUE_OPTIONAL, 'The stub file to load for this generator.'], + ['model', null, InputOption::VALUE_OPTIONAL, 'The model you want to use for this controller.'], ]; /** * The console command name. @@ -50,6 +51,9 @@ class ControllerGenerator extends GeneratorCommand implements ComponentsGenerato public function getUserInputs(): array|null { + $model = $this->checkParameterOrAsk('model', 'Enter the name of the Model that this controller uses', $this->containerName); + $models = Pluralizer::plural($model); + $ui = Str::lower($this->checkParameterOrChoice('ui', 'Select the UI for the controller', ['API', 'WEB'], 0)); $stub = Str::lower( @@ -66,10 +70,6 @@ public function getUserInputs(): array|null $basecontroller = Str::ucfirst($ui) . 'Controller'; - // Name of the model (singular and plural) - $model = $this->containerName; - $models = Pluralizer::plural($model); - $entity = Str::camel($model); $entities = Str::of($entity)->pluralStudly()->camel()->toString();