trait IsPrincipal

Default implementation of the IsPrincipal contract, reading values off public model properties by their configured column names. A model satisfies the contract by using this trait and declaring properties matching the configured column names; the identifier, password, and remember-me token are then resolved dynamically from those properties.

To point a model at differently-named columns, OVERRIDE THE GETTER METHOD (not the property — see note below), e.g. getRememberTokenName().

NOTE: The name properties below cannot be safely overridden by redeclaration in a using class — PHP requires a redeclared trait property to keep an identical default, so a differing value is a fatal error. Override the corresponding getter instead. Returning null from getRememberTokenName() disables remember-me for the model (the token methods become no-ops), which is how a model whose remember-me state lives outside the table opts out.

Properties

protected string $authIdentifierName

The name of the column holding the principal's unique identifier.

protected string $authPasswordName

The name of the column holding the principal's hashed password.

protected string|null $rememberTokenName

The name of the column holding the remember-me token, or null to disable remember-me for the model. Override getRememberTokenName() to change this per model.

Methods

mixed
getAuthIdentifier()

Gets the value of the primary identifier.

string
getAuthIdentifierName()

Gets the name of the primary identifier column.

string|null
getAuthPassword()

Gets the hashed password for this user.

string
getAuthPasswordName()

Gets the name of the password column.

string|null
getRememberToken()

Gets the current remember-me token.

string|null
getRememberTokenName()

Gets the remember-me column name or null to disable the feature for this model.

void
setRememberToken(string $value)

Sets token value to persist.

Details

at line 54
mixed getAuthIdentifier()

Gets the value of the primary identifier.

Return Value

mixed

The value of the primary identifier (e.g. id).

at line 63
string getAuthIdentifierName()

Gets the name of the primary identifier column.

Return Value

string

The name of the primary identifier column.

at line 72
string|null getAuthPassword()

Gets the hashed password for this user.

Return Value

string|null

The hashed password for this user.

at line 81
string getAuthPasswordName()

Gets the name of the password column.

Return Value

string

The name of the password column.

at line 90
string|null getRememberToken()

Gets the current remember-me token.

Return Value

string|null

The current remember-me token, if any.

at line 102
string|null getRememberTokenName()

Gets the remember-me column name or null to disable the feature for this model.

Return Value

string|null

The remember-me column name, or null to disable the feature for this model.

at line 112
void setRememberToken(string $value)

Sets token value to persist.

Parameters

string $value

The token value to persist.

Return Value

void