Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.x] Make Passport's database connection configurable #1738

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

axlon
Copy link
Contributor

@axlon axlon commented Apr 15, 2024

This PR allows developers to configure Passport's database connection without having to extend all of Passport's models.

This change should be fully backwards compatible because:

  • Omitting this configuration will have Laravel use the default connection of the application (which is the current behavior)
  • If someone has extended one of (or multiple of) Passport's models and has overwritten the $connection property, that will take precedence over the config
  • If someone has extended one of (or multiple of) Passport's models and has overwritten the getConnectionName() method this new logic won't be executed at all

@axlon
Copy link
Contributor Author

axlon commented Apr 15, 2024

I just realized Passport's ClientFactory always points to Passport's version of the client model. If someone were to extend the Client model to adjust the connection (which is what prompted me to create this PR) it makes the client factory unusable.

This PR fixes that issue as well, but long term it probably makes more sense to make ClientFactory use Passport::clientModel() to always use the correct model

@taylorotwell taylorotwell merged commit ff4742c into laravel:12.x Apr 15, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants