Skip to content

Commit

Permalink
Merge pull request #28 from mlanin-forks/feature/passport-support
Browse files Browse the repository at this point in the history
Fix Passport bridge
  • Loading branch information
mlanin committed Oct 14, 2016
2 parents d7c06bf + 1a8d0a6 commit 27a4d8f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 58 deletions.
33 changes: 0 additions & 33 deletions src/Passport/Bridge/AccessTokenRepository.php

This file was deleted.

3 changes: 0 additions & 3 deletions src/Passport/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ public function register()
$loader->alias('Laravel\Passport\Client', Client::class);
$loader->alias('Laravel\Passport\PersonalAccessClient', PersonalAccessClient::class);
$loader->alias('Laravel\Passport\Token', Token::class);
$loader->alias('Laravel\Passport\TokenRepository', TokenRepository::class);

$loader->alias('Laravel\Passport\Bridge\AccessTokenRepository', Bridge\AccessTokenRepository::class);
}
}
24 changes: 20 additions & 4 deletions src/Passport/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class Token extends Model
{
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'id';

/**
* The database table used by the model.
*
Expand Down Expand Up @@ -33,7 +40,6 @@ class Token extends Model
* @var array
*/
protected $casts = [
'scopes' => 'array',
'revoked' => 'bool',
];

Expand All @@ -47,11 +53,21 @@ class Token extends Model
];

/**
* Indicates if the model should be timestamped.
* Overwrite scopes setter to handle default passport JSON string
* and save native array.
*
* @var bool
* @param mixed $scopes
*/
public $timestamps = false;
public function setScopesAttribute($scopes)
{
if (is_string($scopes)) {
$scopes = json_decode($scopes, true);
}

// If successfully decoded into array, then it will be saved as array.
// If still string, will be converted to array to preserve consistency.
$this->attributes['scopes'] = (array) $scopes;
}

/**
* Get the client that the token belongs to.
Expand Down
18 changes: 0 additions & 18 deletions src/Passport/TokenRepository.php

This file was deleted.

0 comments on commit 27a4d8f

Please sign in to comment.