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 | $customRelations | from AbstractModel |
|
|
| static | $customCasts | from AbstractModel |
|
|
| static | $defaults | from AbstractModel |
|
|
| protected string|null | $tableAlias | An alias for the table name, used in queries. | from AbstractModel |
|
| int | $id |
|
||
| static protected | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected | $table |
|
||
| protected | $dates |
|
||
| 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. |
|
|
| 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
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
Scope a query to only include records that are visible to a user.
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 77
static
boot()
{@inheritdoc}
in AbstractModel
at
line 97
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 115
getCasts()
{@inheritdoc}
in AbstractModel
at
line 133
mixed
getAttribute(string $key)
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
in AbstractModel
at
line 159
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 175
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 186
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 194
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 206
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 218
__call($method, $arguments)
{@inheritdoc}
in AbstractModel
at
line 227
newModelQuery()
in AbstractModel
at
line 238
qualifyColumn($column)
in AbstractModel
at
line 247
withTableAlias(callable $callback)
in AbstractModel
at
line 262
newCollection(Collection|array $models = [])
in ScopeVisibilityTrait
at
line 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
at
line 81
static AccessToken
generate(int $userId)
Generate an access token for the specified user.
at
line 105
bool
touch(ServerRequestInterface $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 148
BelongsTo
user()
Define the relationship with the owner of this access token.
at
line 159
static protected
scopeValid(Builder $query, Carbon $date)
Filters which tokens are valid at the given date for this particular token type.
Uses the static::$lifetime value by default, can be overridden by children classes.
at
line 172
static protected
scopeExpired(Builder $query, Carbon $date)
Filters which tokens are expired at the given date and ready for garbage collection.
Uses the static::$lifetime value by default, can be overridden by children classes.
at
line 186
static AccessToken|null
findValid(string $token)
Shortcut to find a valid token.
at
line 196
scopeWhereValid(Builder $query, Carbon $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 217
scopeWhereExpired(Builder $query, Carbon $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 240
AccessToken|object
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance according to the access token type.
at
line 265
static array
getModels()
Get the type-to-model map.
at
line 277
static void
setModel(string $type, string $model)
Set the model for the given access token type.