Skip to content

Commit

Permalink
[4.x] Add Generics to HasApiTokens (#544)
Browse files Browse the repository at this point in the history
* generics

* add default
  • Loading branch information
cosmastech authored Nov 14, 2024
1 parent 5716afc commit 7856ef8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/HasApiTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
use DateTimeInterface;
use Illuminate\Support\Str;

/**
* @template TTokenModel of \Illuminate\Database\Eloquent\Model&\Laravel\Sanctum\Contracts\HasAbilities = \Laravel\Sanctum\PersonalAccessToken
*/
trait HasApiTokens
{
/**
* The access token the user is using for the current request.
*
* @var \Laravel\Sanctum\Contracts\HasAbilities
* @var TTokenModel
*/
protected $accessToken;

/**
* Get the access tokens that belong to model.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<TTokenModel, $this>
*/
public function tokens()
{
Expand Down Expand Up @@ -75,7 +78,7 @@ public function generateTokenString()
/**
* Get the access token currently associated with the user.
*
* @return \Laravel\Sanctum\Contracts\HasAbilities
* @return TTokenModel
*/
public function currentAccessToken()
{
Expand All @@ -85,7 +88,7 @@ public function currentAccessToken()
/**
* Set the current access token for the user.
*
* @param \Laravel\Sanctum\Contracts\HasAbilities $accessToken
* @param TTokenModel $accessToken
* @return $this
*/
public function withAccessToken($accessToken)
Expand Down

0 comments on commit 7856ef8

Please sign in to comment.