diff --git a/config/passport.php b/config/passport.php index 06053cd12..ae902d80c 100644 --- a/config/passport.php +++ b/config/passport.php @@ -30,6 +30,19 @@ 'public_key' => env('PASSPORT_PUBLIC_KEY'), + /* + |-------------------------------------------------------------------------- + | Passport Database Connection + |-------------------------------------------------------------------------- + | + | By default, Passport's models will utilize your application's default + | database connection. If you wish to use a different connection you + | may specify the configured name of the database connection here. + | + */ + + 'connection' => env('PASSPORT_CONNECTION'), + /* |-------------------------------------------------------------------------- | Client UUIDs diff --git a/src/AuthCode.php b/src/AuthCode.php index 5c045bacb..feda66b42 100644 --- a/src/AuthCode.php +++ b/src/AuthCode.php @@ -60,4 +60,14 @@ public function client() { return $this->belongsTo(Passport::clientModel()); } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return $this->connection ?? config('passport.connection'); + } } diff --git a/src/Client.php b/src/Client.php index f77c84af8..16e9dfff4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -228,6 +228,16 @@ public function getIncrementing() return Passport::clientUuids() ? false : $this->incrementing; } + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return $this->connection ?? config('passport.connection'); + } + /** * Create a new factory instance for the model. * diff --git a/src/PersonalAccessClient.php b/src/PersonalAccessClient.php index 171b982ab..2e009c2b3 100644 --- a/src/PersonalAccessClient.php +++ b/src/PersonalAccessClient.php @@ -29,4 +29,14 @@ public function client() { return $this->belongsTo(Passport::clientModel()); } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return $this->connection ?? config('passport.connection'); + } } diff --git a/src/RefreshToken.php b/src/RefreshToken.php index df45c4247..cf6a09b56 100644 --- a/src/RefreshToken.php +++ b/src/RefreshToken.php @@ -80,4 +80,14 @@ public function transient() { return false; } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return $this->connection ?? config('passport.connection'); + } } diff --git a/src/Token.php b/src/Token.php index ad3f80817..4f9517e61 100644 --- a/src/Token.php +++ b/src/Token.php @@ -126,4 +126,14 @@ public function transient() { return false; } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return $this->connection ?? config('passport.connection'); + } }