Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Generator/Commands/ContainerApiGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public function getUserInputs(): array|null
'--section' => $sectionName,
'--container' => $containerName,
'--file' => $route['controller'],
'--model' => $model,
'--ui' => $ui,
'--stub' => $route['stub'],
]);
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/Generator/Commands/ContainerWebGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ public function getUserInputs(): array|null
'--section' => $sectionName,
'--container' => $containerName,
'--file' => $route['controller'],
'--model' => $model,
'--ui' => $ui,
'--stub' => $route['stub'],
]);
Expand All @@ -276,6 +277,7 @@ public function getUserInputs(): array|null
'--section' => $sectionName,
'--container' => $containerName,
'--file' => 'Controller',
'--model' => $model,
'--ui' => $ui,
'--stub' => 'crud',
]);
Expand Down
8 changes: 4 additions & 4 deletions src/Generator/Commands/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand All @@ -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();

Expand Down