class AccessToken extends AbstractModel
Traits
Constants
| LAST_ACTIVITY_UPDATE_DIFF |
Difference from the current `last_activity_at` attribute value before `updateLastSeen()` will update the attribute on the DB. Measured in seconds. |
Properties
| bool | $timestamps | Indicates if the model should be timestamped. Turn off by default. | from AbstractModel |
|
| protected callable[] | $afterSaveCallbacks | An array of callbacks to be run once after the model is saved. | from AbstractModel |
|
| protected callable[] | $afterDeleteCallbacks | An array of callbacks to be run once after the model is deleted. | from AbstractModel |
|
| static array | $customCasts | from AbstractModel |
|
|
| static array | $defaults | from AbstractModel |
|
|
| static protected array<class-string, array<string, string>> | $castsCache | Resolved casts, keyed by model class. | from AbstractModel |
|
| protected string|null | $tableAlias | An alias for the table name, used in queries. | from AbstractModel |
|
| array|null | $uniqueKeys |
|
||
| static protected Builder, ?string): void>> | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected | $table |
|
||
| protected | $casts |
|
||
| static protected array | $models | A map of access token types, as specified in the `type` column, to their classes. |
|
|
| string | $type |
|
||
| static protected int | $lifetime | How long this access token should be valid from the time of last activity. |
|
|
| static protected bool | $configurableLifetime | Whether a site may change this type's lifetime. |
|
|
| int | $id |
|
||
| string | $token |
|
||
| int | $user_id |
|
||
| Carbon | $created_at |
|
||
| Carbon|null | $last_activity_at |
|
||
| string | $title |
|
||
| string|null | $last_ip_address |
|
||
| string|null | $last_user_agent |
|
||
| User|null | $user |
|
Methods
Discard the resolved casts, so that newly registered ones are picked up.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
No description
Scope a query to only include records that are visible to a user.
Update the time of last usage of a token.
How long this type of token stays valid, in seconds, taking into account anything the site has configured. Zero means it never expires.
Filters which tokens are valid at the given date for this particular token type.
Filters which tokens are expired at the given date and ready for garbage collection.
This query scope is intended to be used on the base AccessToken object to query for valid tokens of any type.
This query scope is intended to be used on the base AccessToken object to query for expired tokens of any type.
Create a new model instance according to the access token type.
Details
in AbstractModel
at
line 83
static
boot()
in AbstractModel
at
line 100
__construct(array $attributes = [])
in AbstractModel
at
line 115
array
getCasts()
in AbstractModel
at
line 135
static void
flushCastsCache()
Discard the resolved casts, so that newly registered ones are picked up.
in AbstractModel
at
line 143
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 151
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 159
array
releaseAfterSaveCallbacks()
in AbstractModel
at
line 171
array
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 183
newModelQuery()
in AbstractModel
at
line 195
qualifyColumn($column)
in AbstractModel
at
line 204
mixed
withTableAlias(callable $callback)
in AbstractModel
at
line 217
Collection
newCollection(array $models = [])
in AbstractModel
at
line 223
__sleep()
in ScopeVisibilityTrait
at
line 28
static void
registerVisibilityScoper(callable $scoper, string|null $ability = null)
in ScopeVisibilityTrait
at
line 44
Builder
scopeWhereVisibleTo( Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
in ScopeVisibilityTrait
at
line 19
static Builder
whereVisibleTo( User $user)
at
line 95
static AccessToken
generate(int $userId)
Generate an access token for the specified user.
at
line 103
static AccessToken
make(int $userId)
at
line 123
bool
touch($attribute = null, ServerRequestInterface|null $request = null)
Update the time of last usage of a token.
If a request object is provided, the IP address and User Agent will also be logged.
at
line 174
static int
lifetime()
How long this type of token stays valid, in seconds, taking into account anything the site has configured. Zero means it never expires.
Resolved rather than fixed: `config.php` wins, then the setting an admin can change, then the default the class declares. A site that configures nothing keeps the lifetime it has always had.
at
line 188
static bool
hasConfigurableLifetime()
Whether a site may change how long this type of token lasts.
at
line 197
static protected void
scopeValid( Builder $query, Carbon $date)
Filters which tokens are valid at the given date for this particular token type.
Uses the resolved lifetime by default, can be overridden by children classes.
at
line 208
static protected void
scopeExpired( Builder $query, Carbon $date)
Filters which tokens are expired at the given date and ready for garbage collection.
Uses the resolved lifetime by default, can be overridden by children classes.
at
line 221
static AccessToken|null
findValid(string $token)
Shortcut to find a valid token.
at
line 229
void
scopeWhereValid( Builder $query, Carbon|null $date = null)
This query scope is intended to be used on the base AccessToken object to query for valid tokens of any type.
at
line 248
void
scopeWhereExpired( Builder $query, Carbon|null $date = null)
This query scope is intended to be used on the base AccessToken object to query for expired tokens of any type.
at
line 271
AccessToken|object
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance according to the access token type.
at
line 294
static array
getModels()
Get the type-to-model map.
at
line 304
static void
setModel(string $type, string $model)
Set the model for the given access token type.