class DeveloperAccessToken extends AccessToken

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 from AccessToken
static protected Builder, ?string): void>> $visibilityScopers from ScopeVisibilityTrait
protected $table from AccessToken
protected $casts from AccessToken
static protected array $models A map of access token types, as specified in the `type` column, to their classes. from AccessToken
static string $type
static protected int $lifetime
static protected bool $configurableLifetime These are issued deliberately, to be used by a script or an integration for as long as it needs them. An expiry set from the admin panel would break those quietly, weeks later, so this type keeps its own answer.
int $id from AccessToken
string $token from AccessToken
int $user_id from AccessToken
Carbon $created_at from AccessToken
Carbon|null $last_activity_at from AccessToken
string $title from AccessToken
string|null $last_ip_address from AccessToken
string|null $last_user_agent from AccessToken
User|null $user from AccessToken

Methods

static 
boot()

No description

__construct(array $attributes = [])

No description

array
getCasts()

No description

static void
flushCastsCache()

Discard the resolved casts, so that newly registered ones are picked up.

void
afterSave(callable $callback)

Register a callback to be run once after the model is saved.

void
afterDelete(callable $callback)

Register a callback to be run once after the model is deleted.

array
releaseAfterSaveCallbacks()

No description

array
releaseAfterDeleteCallbacks()

No description

newModelQuery()

No description

qualifyColumn($column)

No description

mixed
withTableAlias(callable $callback)

No description

newCollection(array $models = [])

No description

__sleep()

No description

static void
registerVisibilityScoper(callable $scoper, string|null $ability = null)

No description

scopeWhereVisibleTo( Builder $query, User $actor, string $ability = 'view')

Scope a query to only include records that are visible to a user.

static  Builder
whereVisibleTo( User $user)

No description

static  AccessToken
generate(int $userId)

Generate an access token for the specified user.

static  AccessToken
make(int $userId)

No description

bool
touch($attribute = null, ServerRequestInterface|null $request = null)

Update the time of last usage of a token.

user()

No description

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.

static bool
hasConfigurableLifetime()

Whether a site may change how long this type of token lasts.

static void
scopeValid( Builder $query, Carbon $date)

Filters which tokens are valid at the given date for this particular token type.

static void
scopeExpired( Builder $query, Carbon $date)

Filters which tokens are expired at the given date and ready for garbage collection.

static  AccessToken|null
findValid(string $token)

Shortcut to find a valid token.

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.

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.

AccessToken|object
newFromBuilder(array $attributes = [], string|null $connection = null)

Create a new model instance according to the access token type.

static array
getModels()

Get the type-to-model map.

static void
setModel(string $type, string $model)

Set the model for the given access token type.

Details

static boot()

__construct(array $attributes = [])

Parameters

array $attributes

array getCasts()

Return Value

array

static void flushCastsCache()

Discard the resolved casts, so that newly registered ones are picked up.

Return Value

void

void afterSave(callable $callback)

Register a callback to be run once after the model is saved.

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

Register a callback to be run once after the model is deleted.

Parameters

callable $callback

Return Value

void

array releaseAfterSaveCallbacks()

Return Value

array

array releaseAfterDeleteCallbacks()

Return Value

array

newModelQuery()

qualifyColumn($column)

Parameters

$column

mixed withTableAlias(callable $callback)

Parameters

callable $callback

Return Value

mixed

Collection newCollection(array $models = [])

Parameters

array $models

Return Value

Collection

__sleep()

static void registerVisibilityScoper(callable $scoper, string|null $ability = null)

Parameters

callable $scoper
string|null $ability

Return Value

void

Builder scopeWhereVisibleTo( Builder $query, User $actor, string $ability = 'view')

Scope a query to only include records that are visible to a user.

Parameters

Builder $query
User $actor
string $ability

Return Value

Builder

static Builder whereVisibleTo( User $user)

Parameters

User $user

Return Value

Builder

static AccessToken generate(int $userId)

Generate an access token for the specified user.

Parameters

int $userId

Return Value

AccessToken

static AccessToken make(int $userId)

Parameters

int $userId

Return Value

AccessToken

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.

Parameters

$attribute
ServerRequestInterface|null $request

Return Value

bool

BelongsTo user()

Return Value

BelongsTo

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.

Return Value

int

static bool hasConfigurableLifetime()

Whether a site may change how long this type of token lasts.

Return Value

bool

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.

Parameters

Builder $query
Carbon $date

Return Value

void

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.

Parameters

Builder $query
Carbon $date

Return Value

void

static AccessToken|null findValid(string $token)

Shortcut to find a valid token.

Parameters

string $token Token as sent by the user. We allow non-string values like null so we can directly feed any value from a request.

Return Value

AccessToken|null

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.

Parameters

Builder $query
Carbon|null $date

Return Value

void

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.

Parameters

Builder $query
Carbon|null $date

Return Value

void

AccessToken|object newFromBuilder(array $attributes = [], string|null $connection = null)

Create a new model instance according to the access token type.

Parameters

array $attributes
string|null $connection

Return Value

AccessToken|object

static array getModels()

Get the type-to-model map.

Return Value

array

static void setModel(string $type, string $model)

Set the model for the given access token type.

Parameters

string $type
string $model The class name of the model for that type.

Return Value

void