Skip to content

Commit d40f9cf

Browse files
committed
🔨 improve on createModel() method to create sub-directory models
Signed-off-by: otengkwame <developerkwame@gmail.com>
1 parent 1ba5250 commit d40f9cf

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

Core/core/Console/Console.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,10 @@ protected static function createModel(...$args)
453453
{
454454
$module = $args[0];
455455
$modelName = '';
456+
$location = "Models";
457+
$lastArg = $args[3];
456458

457-
$nonModuleModel = str_contains($args[0], '--name');
459+
$nonModuleModel = str_contains($module, '--name');
458460

459461
if ($nonModuleModel) {
460462
$args[3] = $args[2];
@@ -486,6 +488,10 @@ protected static function createModel(...$args)
486488
if (isset($args[3])) {
487489
$removeModel = $args[3];
488490
}
491+
492+
if ($args[3] == '--dir') {
493+
$location = $lastArg;
494+
}
489495

490496
if ($modelType == '--remove-model') {
491497
$output = " \n";
@@ -494,8 +500,16 @@ protected static function createModel(...$args)
494500
exit;
495501
}
496502

503+
if ($modelType == '--dir') {
504+
$output = " \n";
505+
$output .= ConsoleColor::white(" Please check docs for correct syntax to create:model", 'light', 'red') . " \n";
506+
echo $output . "\n";
507+
exit;
508+
}
509+
497510
if ($nonModuleModel) {
498-
$command = Console::phpCommand() . 'create/createnonmodulemodel/' . $modelName . '/' . $modelType. '/' . $removeModel;
511+
$location = str_replace('/','_', $location);
512+
$command = Console::phpCommand() . 'create/createnonmodulemodel/' . $modelName . '/' . $modelType. '/' . $removeModel. '/' . $location;
499513
static::runSystemCommand($command);
500514
return;
501515
}

0 commit comments

Comments
 (0)