diff --git a/config/ide-helper.php b/config/ide-helper.php index 51fcdf24a..605bfdda8 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -316,4 +316,26 @@ // 'ide-helper:models --nowrite', ], + /* + |-------------------------------------------------------------------------- + | Allow discovery in multiple active databases + |-------------------------------------------------------------------------- + | + | When running IDE helper in a multi-tenant context, you would need to + | indicate the database to match the different connections used by your + | models. + | + | This is required if your application has models dispatched both in a common + | database (called landlord or system depending on the libraries) and in a + | tenant specific database (one which will contain data which can vary between + | tenants) + | + | In other cases (single database or no common database), you can leave + | this commented. + */ +// 'db_mapping'=> [ +// // laravel connection name => real database name +// 'landlord' => 'homestead', +// 'tenant' => 'test_tenant', +// ], ]; diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index c3c08c445..a723326a4 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -467,8 +467,9 @@ public function getPropertiesFromTable($model) } $databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName); } - - $database = null; + + $connectionName = $model->getConnection()->getName(); + $database = $this->laravel['config']->get("ide-helper.db_mapping.$connectionName"); if (strpos($table, '.')) { [$database, $table] = explode('.', $table); }