From 7856ef8993d6bff87519860944f68d11b6339fb8 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com> Date: Thu, 14 Nov 2024 10:33:08 -0500 Subject: [PATCH] [4.x] Add Generics to `HasApiTokens` (#544) * generics * add default --- src/HasApiTokens.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/HasApiTokens.php b/src/HasApiTokens.php index d59fad3..d3ff5ea 100644 --- a/src/HasApiTokens.php +++ b/src/HasApiTokens.php @@ -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 */ public function tokens() { @@ -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() { @@ -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)