diff --git a/config/passport.php b/config/passport.php index 1c962adcf..162f1f84a 100644 --- a/config/passport.php +++ b/config/passport.php @@ -51,9 +51,9 @@ | Passport Storage Driver |-------------------------------------------------------------------------- | - | This configuration options determines the storage driver that will - | be used to store Passport's data. In addition, you may set any - | custom options as needed by the particular driver you choose. + | This configuration value allows you to customize the storage options + | for Passport, such as the database connection that should be used + | by Passport's internal database models which store tokens, etc. | */ diff --git a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php index 5a8c232f4..0eabf059c 100644 --- a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php +++ b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php @@ -23,16 +23,6 @@ public function __construct() $this->schema = Schema::connection($this->getConnection()); } - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); - } - /** * Run the migrations. * @@ -59,4 +49,14 @@ public function down() { $this->schema->dropIfExists('oauth_auth_codes'); } + + /** + * Get the migration connection name. + * + * @return string|null + */ + public function getConnection() + { + return config('passport.storage.database.connection'); + } } diff --git a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php index a30107471..67c682d5f 100644 --- a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php +++ b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php @@ -23,16 +23,6 @@ public function __construct() $this->schema = Schema::connection($this->getConnection()); } - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); - } - /** * Run the migrations. * @@ -61,4 +51,14 @@ public function down() { $this->schema->dropIfExists('oauth_access_tokens'); } + + /** + * Get the migration connection name. + * + * @return string|null + */ + public function getConnection() + { + return config('passport.storage.database.connection'); + } } diff --git a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php index 23ea4a1b3..fe70957c1 100644 --- a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php +++ b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php @@ -23,16 +23,6 @@ public function __construct() $this->schema = Schema::connection($this->getConnection()); } - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); - } - /** * Run the migrations. * @@ -57,4 +47,14 @@ public function down() { $this->schema->dropIfExists('oauth_refresh_tokens'); } + + /** + * Get the migration connection name. + * + * @return string|null + */ + public function getConnection() + { + return config('passport.storage.database.connection'); + } } diff --git a/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php b/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php index 561313578..c408248f5 100644 --- a/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php +++ b/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php @@ -23,16 +23,6 @@ public function __construct() $this->schema = Schema::connection($this->getConnection()); } - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); - } - /** * Run the migrations. * @@ -56,4 +46,14 @@ public function down() { $this->schema->dropIfExists('oauth_personal_access_clients'); } + + /** + * Get the migration connection name. + * + * @return string|null + */ + public function getConnection() + { + return config('passport.storage.database.connection'); + } } diff --git a/src/AuthCode.php b/src/AuthCode.php index 44e9c20e3..94441b5f7 100644 --- a/src/AuthCode.php +++ b/src/AuthCode.php @@ -60,22 +60,22 @@ class AuthCode extends Model protected $keyType = 'string'; /** - * Get the current connection name for the model. + * Get the client that owns the authentication code. * - * @return string|null + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function getConnectionName() + public function client() { - return config('passport.storage.database.connection') ?? $this->connection; + return $this->belongsTo(Passport::clientModel()); } /** - * Get the client that owns the authentication code. + * Get the current connection name for the model. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return string|null */ - public function client() + public function getConnectionName() { - return $this->belongsTo(Passport::clientModel()); + return config('passport.storage.database.connection') ?? $this->connection; } } diff --git a/src/Client.php b/src/Client.php index 083a10112..9fbc155bd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -65,16 +65,6 @@ public static function boot() }); } - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } - /** * Get the user that the client belongs to. * @@ -189,4 +179,14 @@ public function getIncrementing() { return Passport::clientUuids() ? false : $this->incrementing; } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return config('passport.storage.database.connection') ?? $this->connection; + } } diff --git a/src/PersonalAccessClient.php b/src/PersonalAccessClient.php index 9d26593ea..1d35b0504 100644 --- a/src/PersonalAccessClient.php +++ b/src/PersonalAccessClient.php @@ -21,22 +21,22 @@ class PersonalAccessClient extends Model protected $guarded = []; /** - * Get the current connection name for the model. + * Get all of the authentication codes for the client. * - * @return string|null + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function getConnectionName() + public function client() { - return config('passport.storage.database.connection') ?? $this->connection; + return $this->belongsTo(Passport::clientModel()); } /** - * Get all of the authentication codes for the client. + * Get the current connection name for the model. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return string|null */ - public function client() + public function getConnectionName() { - return $this->belongsTo(Passport::clientModel()); + return config('passport.storage.database.connection') ?? $this->connection; } } diff --git a/src/RefreshToken.php b/src/RefreshToken.php index ab31f5822..7927662bf 100644 --- a/src/RefreshToken.php +++ b/src/RefreshToken.php @@ -59,16 +59,6 @@ class RefreshToken extends Model */ public $timestamps = false; - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } - /** * Get the access token that the refresh token belongs to. * @@ -98,4 +88,14 @@ public function transient() { return false; } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return config('passport.storage.database.connection') ?? $this->connection; + } } diff --git a/src/Token.php b/src/Token.php index 1e6cf51f6..1c7bb73b2 100644 --- a/src/Token.php +++ b/src/Token.php @@ -60,16 +60,6 @@ class Token extends Model */ public $timestamps = false; - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } - /** * Get the client that the token belongs to. * @@ -168,4 +158,14 @@ public function transient() { return false; } + + /** + * Get the current connection name for the model. + * + * @return string|null + */ + public function getConnectionName() + { + return config('passport.storage.database.connection') ?? $this->connection; + } }