Skip to content

Commit 7856ef8

Browse files
authored
[4.x] Add Generics to HasApiTokens (#544)
* generics * add default
1 parent 5716afc commit 7856ef8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/HasApiTokens.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
use DateTimeInterface;
66
use Illuminate\Support\Str;
77

8+
/**
9+
* @template TTokenModel of \Illuminate\Database\Eloquent\Model&\Laravel\Sanctum\Contracts\HasAbilities = \Laravel\Sanctum\PersonalAccessToken
10+
*/
811
trait HasApiTokens
912
{
1013
/**
1114
* The access token the user is using for the current request.
1215
*
13-
* @var \Laravel\Sanctum\Contracts\HasAbilities
16+
* @var TTokenModel
1417
*/
1518
protected $accessToken;
1619

1720
/**
1821
* Get the access tokens that belong to model.
1922
*
20-
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
23+
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<TTokenModel, $this>
2124
*/
2225
public function tokens()
2326
{
@@ -75,7 +78,7 @@ public function generateTokenString()
7578
/**
7679
* Get the access token currently associated with the user.
7780
*
78-
* @return \Laravel\Sanctum\Contracts\HasAbilities
81+
* @return TTokenModel
7982
*/
8083
public function currentAccessToken()
8184
{
@@ -85,7 +88,7 @@ public function currentAccessToken()
8588
/**
8689
* Set the current access token for the user.
8790
*
88-
* @param \Laravel\Sanctum\Contracts\HasAbilities $accessToken
91+
* @param TTokenModel $accessToken
8992
* @return $this
9093
*/
9194
public function withAccessToken($accessToken)

0 commit comments

Comments
 (0)