class SessionAccessToken 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 $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 from AccessToken
static protected $visibilityScopers from ScopeVisibilityTrait
protected $table from AccessToken
protected $dates from AccessToken
static protected array $models A map of access token types, as specified in the `type` column, to their classes. from AccessToken
static $type
static protected $lifetime
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
protected $hidden

Methods

static 
boot()

{@inheritdoc}

__construct(array $attributes = [])

{@inheritdoc}

getCasts()

{@inheritdoc}

mixed
getAttribute(string $key)

Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.

mixed
getCustomRelation(string $name)

Get a custom relation object.

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.

callable[]
releaseAfterSaveCallbacks()

No description

callable[]
releaseAfterDeleteCallbacks()

No description

__call($method, $arguments)

{@inheritdoc}

newModelQuery()

No description

qualifyColumn($column)

No description

withTableAlias(callable $callback)

No description

newCollection(Collection|array $models = [])

No description

static 
registerVisibilityScoper($scoper, $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 AccessToken
generate(int $userId)

Generate an access token for the specified user.

bool
touch(ServerRequestInterface $request = null)

Update the time of last usage of a token.

BelongsTo
user()

Define the relationship with the owner of this access token.

static 
scopeValid(Builder $query, Carbon $date)

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

static 
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.

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.

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.

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()

{@inheritdoc}

__construct(array $attributes = [])

{@inheritdoc}

Parameters

array $attributes

getCasts()

{@inheritdoc}

mixed getAttribute(string $key)

Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.

Parameters

string $key

Return Value

mixed

protected mixed getCustomRelation(string $name)

Get a custom relation object.

Parameters

string $name

Return Value

mixed

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

callable[] releaseAfterSaveCallbacks()

Return Value

callable[]

callable[] releaseAfterDeleteCallbacks()

Return Value

callable[]

__call($method, $arguments)

{@inheritdoc}

Parameters

$method
$arguments

newModelQuery()

qualifyColumn($column)

Parameters

$column

withTableAlias(callable $callback)

Parameters

callable $callback

newCollection(Collection|array $models = [])

Parameters

Collection|array $models

static registerVisibilityScoper($scoper, $ability = null)

Parameters

$scoper
$ability

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

static AccessToken generate(int $userId)

Generate an access token for the specified user.

Parameters

int $userId

Return Value

AccessToken

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.

Parameters

ServerRequestInterface $request

Return Value

bool

BelongsTo user()

Define the relationship with the owner of this access token.

Return Value

BelongsTo

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.

Parameters

Builder $query
Carbon $date

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.

Parameters

Builder $query
Carbon $date

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

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.

Parameters

Builder $query
Carbon $date

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.

Parameters

Builder $query
Carbon $date

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 The access token type.
string $model The class name of the model for that type.

Return Value

void