class AccessToken extends AbstractModel

Constants

LAST_ACTIVITY_UPDATE_DIFF

<p>Difference from the current <code>last_activity_at</code> attribute value before <code>updateLastSeen()</code> will update the attribute on the DB. Measured in seconds.</p>

Properties

bool $timestamps <p>Indicates if the model should be timestamped. Turn off by default.</p> from AbstractModel
protected callable[] $afterSaveCallbacks <p>An array of callbacks to be run once after the model is saved.</p> from AbstractModel
protected callable[] $afterDeleteCallbacks <p>An array of callbacks to be run once after the model is deleted.</p> from AbstractModel
static $customRelations from AbstractModel
static $dateAttributes from AbstractModel
static $defaults from AbstractModel
int $id
protected $table
protected $dates
static protected array $models <p>A map of access token types, as specified in the <code>type</code> column, to their classes.</p>
string $type
static protected int $lifetime <p>How long this access token should be valid from the time of last activity.</p>
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

static 
boot()

<p>{@inheritdoc}</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

array
getDates()

<p>Get the attributes that should be converted to dates.</p>

mixed
getAttribute(string $key)

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

mixed
getCustomRelation(string $name)

<p>Get a custom relation object.</p>

void
afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

void
afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

callable[]
releaseAfterSaveCallbacks()

No description

callable[]
releaseAfterDeleteCallbacks()

No description

__call($method, $arguments)

<p>{@inheritdoc}</p>

static AccessToken
generate(int $userId)

<p>Generate an access token for the specified user.</p>

bool
touch(ServerRequestInterface $request = null)

<p>Update the time of last usage of a token.</p>

BelongsTo
user()

<p>Define the relationship with the owner of this access token.</p>

static 
scopeValid(Builder $query, Carbon $date)

<p>Filters which tokens are valid at the given date for this particular token type.</p>

static 
scopeExpired(Builder $query, Carbon $date)

<p>Filters which tokens are expired at the given date and ready for garbage collection.</p>

static AccessToken|null
findValid(string $token)

<p>Shortcut to find a valid token.</p>

scopeWhereValid(Builder $query, Carbon $date = null)

<p>This query scope is intended to be used on the base AccessToken object to query for valid tokens of any type.</p>

scopeWhereExpired(Builder $query, Carbon $date = null)

<p>This query scope is intended to be used on the base AccessToken object to query for expired tokens of any type.</p>

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

<p>Create a new model instance according to the access token type.</p>

static array
getModels()

<p>Get the type-to-model map.</p>

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

<p>Set the model for the given access token type.</p>

Details

static boot()

<p>{@inheritdoc}</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

Parameters

array $attributes

array getDates()

<p>Get the attributes that should be converted to dates.</p>

Return Value

array

mixed getAttribute(string $key)

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

Parameters

string $key

Return Value

mixed

protected mixed getCustomRelation(string $name)

<p>Get a custom relation object.</p>

Parameters

string $name

Return Value

mixed

void afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

Parameters

callable $callback

Return Value

void

callable[] releaseAfterSaveCallbacks()

Return Value

callable[]

callable[] releaseAfterDeleteCallbacks()

Return Value

callable[]

__call($method, $arguments)

<p>{@inheritdoc}</p>

Parameters

$method
$arguments

static AccessToken generate(int $userId)

<p>Generate an access token for the specified user.</p>

Parameters

int $userId

Return Value

AccessToken

bool touch(ServerRequestInterface $request = null)

<p>Update the time of last usage of a token.</p>

<p>If a request object is provided, the IP address and User Agent will also be logged.</p>

Parameters

ServerRequestInterface $request

Return Value

bool

BelongsTo user()

<p>Define the relationship with the owner of this access token.</p>

Return Value

BelongsTo

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

<p>Filters which tokens are valid at the given date for this particular token type.</p>

<p>Uses the static::$lifetime value by default, can be overridden by children classes.</p>

Parameters

Builder $query
Carbon $date

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

<p>Filters which tokens are expired at the given date and ready for garbage collection.</p>

<p>Uses the static::$lifetime value by default, can be overridden by children classes.</p>

Parameters

Builder $query
Carbon $date

static AccessToken|null findValid(string $token)

<p>Shortcut to find a valid token.</p>

Parameters

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

Return Value

AccessToken|null

scopeWhereValid(Builder $query, Carbon $date = null)

<p>This query scope is intended to be used on the base AccessToken object to query for valid tokens of any type.</p>

Parameters

Builder $query
Carbon $date

scopeWhereExpired(Builder $query, Carbon $date = null)

<p>This query scope is intended to be used on the base AccessToken object to query for expired tokens of any type.</p>

Parameters

Builder $query
Carbon $date

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

<p>Create a new model instance according to the access token type.</p>

Parameters

array $attributes
string|null $connection

Return Value

AccessToken|object

static array getModels()

<p>Get the type-to-model map.</p>

Return Value

array

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

<p>Set the model for the given access token type.</p>

Parameters

string $type <p>The access token type.</p>
string $model <p>The class name of the model for that type.</p>

Return Value

void