trait HasApiTokens

Properties

protected null|TToken $accessToken

The access token the user is using for the current request.

Methods

static void
bootHasApiTokens()

Bootstrap the API token concern.

tokens()

Get the access tokens that belong to model.

newTokenRelation()

Instantiate the personal access token relationship.

bool
tokenCan(UnitEnum|string $ability)

Determine if the current API token has a given ability.

bool
tokenCant(UnitEnum|string $ability)

Determine if the current API token does not have a given ability.

createToken(string $name, array $abilities = ['*'], DateTimeInterface|null $expiresAt = null)

Create a new personal access token for the user.

string
generateTokenString()

Generate the token string.

currentAccessToken()

Get the access token currently associated with the user.

withAccessToken(HasAbilities|null $accessToken)

Set the current access token for the user.

Details

at line 30
static void bootHasApiTokens()

Bootstrap the API token concern.

Return Value

void

at line 50
PersonalAccessTokenRelation tokens()

Get the access tokens that belong to model.

at line 58
protected PersonalAccessTokenRelation newTokenRelation()

Instantiate the personal access token relationship.

at line 81
bool tokenCan(UnitEnum|string $ability)

Determine if the current API token has a given ability.

Parameters

UnitEnum|string $ability

Return Value

bool

at line 89
bool tokenCant(UnitEnum|string $ability)

Determine if the current API token does not have a given ability.

Parameters

UnitEnum|string $ability

Return Value

bool

at line 99
NewAccessToken createToken(string $name, array $abilities = ['*'], DateTimeInterface|null $expiresAt = null)

Create a new personal access token for the user.

Parameters

string $name
array $abilities
DateTimeInterface|null $expiresAt

Return Value

NewAccessToken

at line 119
string generateTokenString()

Generate the token string.

Return Value

string

at line 134
HasAbilities|null currentAccessToken()

Get the access token currently associated with the user.

Return Value

HasAbilities|null

at line 145
HasApiTokens withAccessToken(HasAbilities|null $accessToken)

Set the current access token for the user.

Parameters

HasAbilities|null $accessToken

Return Value

HasApiTokens