Skip to content

Commit

Permalink
[12.x] Make Passport's database connection configurable (#1738)
Browse files Browse the repository at this point in the history
* Make Passport's database connection configurable

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
axlon and taylorotwell authored Apr 15, 2024
1 parent c46a88b commit ff4742c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
10 changes: 10 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 10 additions & 0 deletions src/PersonalAccessClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
10 changes: 10 additions & 0 deletions src/RefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
10 changes: 10 additions & 0 deletions src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit ff4742c

Please sign in to comment.