Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Add Generics to HasApiTokens #544

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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