diff --git a/config/ide-helper.php b/config/ide-helper.php index f9110aae7..bb7c0ac8c 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -230,6 +230,26 @@ ], + /* + |-------------------------------------------------------------------------- + | Support for custom DB connection information + |-------------------------------------------------------------------------- + | + | This setting allow you to override settings in your database config. This is useful for when models may + | connection to difference databases i.e., you have a multi-tenancy setup. + | + | Complete the overrider with the specific entries you wish to override and these will be applied to the + | config('database.connections') config array: + | + | "tenant" => array( + | "database" => "test_tenant_database", + | ), + | + */ + 'db_connection_overrides' => [ + + ], + /* |-------------------------------------------------------------------------- | Support for camel cased models diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index d40b64514..f0dff6d77 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -140,6 +140,11 @@ public function handle() { $this->filename = $this->laravel['config']->get('ide-helper.models_filename', '_ide_helper_models.php'); $filename = $this->option('filename') ?? $this->filename; + $db_overrides = $this->laravel['config']->get('ide-helper.db_connection_overrides'); + if (is_array($db_overrides)) { + $db_overrides = array_replace_recursive($this->laravel['config']->get('database.connections'), $db_overrides); + $this->laravel['config']->set('database.connections', $db_overrides); + } $this->write = $this->option('write'); $this->write_mixin = $this->option('write-mixin'); $this->dirs = array_merge( @@ -931,14 +936,14 @@ protected function createPhpDocs($class) // remove the already existing tag to prevent duplicates foreach ($phpdoc->getTagsByName('mixin') as $tag) { - if($tag->getContent() === $eloquentClassNameInModel) { + if ($tag->getContent() === $eloquentClassNameInModel) { $phpdoc->deleteTag($tag); } } $phpdoc->appendTag(Tag::createInstance('@mixin ' . $eloquentClassNameInModel, $phpdoc)); } - + if ($this->phpstorm_noinspections) { /** * Facades, Eloquent API