From c3afed040e5d8aef5c1baf276d90f62b6e2cc6ae Mon Sep 17 00:00:00 2001 From: Richard Browne Date: Fri, 2 Sep 2022 11:23:31 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A7=20Add=20a=20new=20config=20ent?= =?UTF-8?q?ry=20for=20the=20db=20connection=20overrides.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/ide-helper.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 From 6e4c02567c05920be36697b3f33b65a1eb1a7fb4 Mon Sep 17 00:00:00 2001 From: Richard Browne Date: Fri, 2 Sep 2022 11:23:47 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A7=20Use=20the=20db=20connection?= =?UTF-8?q?=20overrides=20if=20they're=20set.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Console/ModelsCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index d40b64514..6693261cf 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( From a9ab12f0c66dd2c8d7f8081dd7331b74977f14fb Mon Sep 17 00:00:00 2001 From: Richard Browne Date: Fri, 2 Sep 2022 11:42:31 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=92=85=20Style=20corrections.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Console/ModelsCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 6693261cf..f0dff6d77 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -936,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