Allow table inspection when the database connection config is generated on the fly. #1372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
For applications were the developer is using a multi-tenancy setup, utilising multiple databases i.e., one for the landlord and many for the tenants, the database config definition is usually altered by the multi-tenancy package when a new tenant is activated.
This however, means that the
database.connections.tenant
config is usually missing a value fordatabase.connections.tenant.database
so laravel-ide-helper cannot connect to the database to inspect the properties.This modification adds a new config entry into the
ide-helper.php
config file that allows for overrides for thedatabase.connections
array to be set. When the model generator command is run, these overrides are set in the in-memory config values, such that when the connection is used to inspect the database schema, it has the full information. However, this doesn't have a knock on effect that thedatabase.php
config file needs to be constantly altered and then reset.The user can also elect to use an
env()
value in theide-helper.db_connections_override
array so that between developers the database name can be set as needed.This has been referenced in the following issues:
#1141
#1280
An attempt at a pull request #1285 was submitted by vpratfr which attempts a similar idea, but requires specifying a specific connection to use and alters the connection logic. I can see that this could have "breaking" implications and makes things difficult to test. This PR uses the existing connections and allows for the user to specify a database name (in essence) i.e., it's there if the user wants to use it, but if not nothing really changes.
Type of change
Checklist
composer fix-style