Skip to content
Open
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
16 changes: 14 additions & 2 deletions src/commands/make/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,30 @@ export default class MakeController extends Common {
let type = (await this.getListInput('What type of controller is this?', ['Basic', 'Resource', 'API'])).toLowerCase() as ControllerType;

let refModel = false;
let refParent = false;
let modelToUse = '';
let parentToUse = '';
let modelToUseCommands = [];
if (type != 'basic') {
// Determine the model reference
refModel = await this.getYesNo('Should this reference a model?');
if (refModel) {
modelToUse = await this.getInput('What is the name of the model?');
modelToUseCommands.push(`--model=${modelToUse}`);

// Determine the parent model reference
refParent = await this.getYesNo('Should this reference a parent model?');
if (refParent) {
parentToUse = await this.getInput('What is the name of the parent model?');
modelToUseCommands.push(`--parent=${parentToUse}`);
}

modelToUseCommands.push(`--no-interaction`);
}
}

let modelToUseCommand = refModel ? `--model=${modelToUse} --no-interaction` : '';
let typeCommand = type === 'resource' ? '--resource' : type === 'api' ? '--api' : '';
let command = `make:controller ${ctrlName} ${typeCommand} ${modelToUseCommand}`;
let command = `make:controller ${ctrlName} ${typeCommand} ${modelToUseCommands.join(' ')}`;
// let command = `make:controller ${ctrlName} ${isResource ? '--resource' : ''} ${isAPI ? '--api' : ''}`.trim()

// Generate the controller
Expand Down