diff --git a/src/Command/ModelCommand.php b/src/Command/ModelCommand.php index 78f891c3..f90b48e5 100644 --- a/src/Command/ModelCommand.php +++ b/src/Command/ModelCommand.php @@ -1,4 +1,5 @@ $tmpModelName, + 'className' => $tmpModelName, 'foreignKey' => $fieldName, ]; if ($schema->getColumn($fieldName)['null'] === false) { $assoc['joinType'] = 'INNER'; } } - if ($this->plugin && empty($assoc['className'])) { $assoc['className'] = $this->plugin . '.' . $assoc['alias']; } + if (!empty($assoc['className'])) { + $assoc['alias'] = $assoc['className'] . '_' . $model->getAlias() . '_' . $fieldName; + } $associations['belongsTo'][] = $assoc; } @@ -711,7 +716,7 @@ public function getEntityPropertySchema(Table $model): array if ($entityClass === '\Cake\ORM\Entity') { $namespace = Configure::read('App.namespace'); - [$plugin, ] = pluginSplit($association->getTarget()->getRegistryAlias()); + [$plugin,] = pluginSplit($association->getTarget()->getRegistryAlias()); if ($plugin !== null) { $namespace = $plugin; } @@ -1355,7 +1360,7 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar ])->addOption('skip-relation-check', [ 'boolean' => true, 'help' => 'Generate relations for all "example_id" fields' - . ' without checking the database if a table "examples" exists.', + . ' without checking the database if a table "examples" exists.', ])->setEpilog( 'Omitting all arguments and options will list the table names you can generate models for.' );