User
class User extends ORM implements AuthorizableInterface, MemberInterface, UserEntityInterface
User.
Traits
Constants
PRIMARY_KEY_TYPE_INCREMENTING |
Incrementing primary key. |
PRIMARY_KEY_TYPE_UUID |
UUID primary key. |
PRIMARY_KEY_TYPE_CUSTOM |
Custom primary key. |
PRIMARY_KEY_TYPE_NONE |
No primary key. |
Properties
protected string | $connectionName | Connection name to use for the model. | from ORM |
static protected ConnectionManager | $connectionManager | Connection manager instance. | from ORM |
static protected array | $traitHooks | ORM query builder hooks. | from ORM |
static protected array | $traitCasts | Trait casts. | from ORM |
protected string | $tableName | Table name. | |
protected string | $foreignKeyName | Foreign key name. | from ORM |
protected string | $primaryKey | Primary key. | from ORM |
protected int | $primaryKeyType | Does this table have an auto increment primary index? | from ORM |
protected bool | $isPersisted | Has the record been loaded from/saved to a database? | from ORM |
protected array | $columns | Column values. | from ORM |
protected array | $original | Original column values. | from ORM |
protected array | $including | Relations to eager load. | from ORM |
protected array | $related | Related records. | from ORM |
protected array | $cast | Type casting. | |
protected array | $assignable | Columns that can be set through mass assignment. | from ORM |
protected array | $protected | Columns and relations that are excluded from the array and json representations of the record. | from ORM |
protected string | $dateOutputFormat | Date format used when returning array and json representations of the record. | from ORM |
protected AuthorizerInterface | $authorizer | Authorizer. | from AuthorizableTrait |
int | $id | ||
Time | $created_at | ||
Time | $updated_at | ||
string | |||
string | $username | ||
string | $password | ||
string | $ip | ||
string | $action_token | ||
string | $access_token | ||
int | $activated | ||
int | $banned | ||
int | $failed_attempts | ||
Time|null | $last_fail_at | ||
Time|null | $locked_until | ||
ResultSet | $groups |
Methods
Constructor.
Returns TRUE if the model has included the relationship and FALSE if not.
Returns TRUE if it's probable that $name is a relation and FALSE if not.
Assigns the column values to the model.
Returns a record using the value of its primary key.
Creates a new record and returns the model.
Returns a HasOnePolymorphic relation.
Returns a HasManyPolymorphic relation.
Returns a ManyToMany relation.
Returns a BelongsToPolymorphic relation.
Excludes the chosen columns and relations from array and json representations of the record.
Exposes the chosen columns and relations in the array and json representations of the record.
Forwards static method calls to the query builder.
Returns TRUE if allowed to perform the action on the entity and FALSE if not.
Returns the column that holds the "created at" timestamp.
Returns the column that holds the "updated at" timestamp.
Allows you to update the "updated at" timestamp without modifying any data.
User groups.
Returns a hasher instance.
Password mutator.
Generates a new token.
No description
Sets the user email address.
Returns the user email address.
Sets the username.
Returns the user username.
Sets the user password.
Returns the user password hash.
Sets the user IP address.
Returns the user IP address.
Generates a new action token.
Returns the user action token.
Generates a new access token.
Returns the user access token.
Activates the user.
Deactivates the user.
Returns TRUE of the user is activated and FALSE if not.
Bans the user.
Unbans the user.
Returns TRUE if the user is banned and FALSE if not.
Returns TRUE if the provided password is correct and FALSE if not.
Returns TRUE if a user is a member of the group(s) and FALSE if not.
Returns null if the account isn't locked and a date time instance if its locked.
Unlocks the account.
Returns TRUE if the account is locked and FALSE if not.
Returns the number of failed login attempts.
Gets the time of the last failed attempt.
Throttles login attempts.
Resets the login throttling.
Details
in ORM at line 205
__construct(array $columns = [], bool $raw = false, bool $whitelist = true, bool $isPersisted = false)
Constructor.
in ORM at line 222
__clone()
Making sure that cloning returns a "fresh copy" of the record.
in ORM at line 239
static
setConnectionManager(ConnectionManager $connectionManager)
Set the connection manager.
in ORM at line 249
Connection
getConnection()
Returns the connection of the model.
in ORM at line 264
bool
isPersisted()
Has the record been loaded from/saved to a database?
in ORM at line 272
synchronize()
Synchronizes the original values with the modified values.
in ORM at line 282
protected string
getDateFormat()
Gets the date format from the query builder compiler.
in ORM at line 297
protected
registerHooksAndCasts()
Registers hooks and casts.
in ORM at line 327
protected array
bindHooks(array $hooks)
Binds the hooks to the current instance of "$this".
in ORM at line 345
array
getHooks(string $event)
Returns hooks for the chosen event.
in ORM at line 356
protected string
getClassShortName(string|null $className = null)
Returns the short name of a class.
in ORM at line 375
string
getTable()
Returns the table name of the model.
in ORM at line 390
string
getPrimaryKey()
Returns the primary key of the table.
in ORM at line 400
int
getPrimaryKeyType()
Returns the primary key type.
in ORM at line 410
mixed
getPrimaryKeyValue()
Returns the primary key value.
in ORM at line 420
string
getForeignKey()
Returns the foreign key of the table.
in ORM at line 435
string
getClass()
Returns the namespaced class name of the model.
in ORM at line 445
setIncludes(array $includes)
Sets the relations to eager load.
in ORM at line 455
array
getIncludes()
Returns the relations to eager load.
in ORM at line 466
setRelated(string $relation, mixed $related)
Sets eagerly loaded related records.
in ORM at line 477
bool
includes(string $relation)
Returns TRUE if the model has included the relationship and FALSE if not.
in ORM at line 488
$this
include(string|array $includes)
Eager loads relations on the model.
in ORM at line 503
array
getRelated()
Returns the related records array.
in ORM at line 515
protected mixed
cast(string $name, mixed $value)
Cast value to the appropriate type.
in ORM at line 545
setRawColumnValue(string $name, mixed $value)
Sets a raw column value.
in ORM at line 556
setColumnValue(string $name, mixed $value)
Sets a column value.
in ORM at line 576
mixed
getRawColumnValue(string $name)
Gets a raw column value.
in ORM at line 587
mixed
getColumnValue(string $name)
Returns a column value.
in ORM at line 603
protected bool
isRelation(string $name)
Returns TRUE if it's probable that $name is a relation and FALSE if not.
in ORM at line 614
mixed
getValue(string $name)
Gets a column value or relation.
in ORM at line 645
array
getRawColumnValues()
Returns the columns array.
in ORM at line 656
protected
setColumValues(array $columns, bool $raw)
Sets column values.
in ORM at line 689
$this
assign(array $columns, bool $raw = false, bool $whitelist = true)
Assigns the column values to the model.
in ORM at line 718
__set(string $name, mixed $value)
Set column value using overloading.
in ORM at line 729
mixed
__get(string $name)
Get column value or relation using overloading.
in ORM at line 740
bool
__isset(string $name)
Checks if a column or relation is set using overloading.
in ORM at line 755
__unset(string $name)
Unset column value or relation using overloading.
in ORM at line 777
static ORM
get(mixed $id, array $columns = [])
Returns a record using the value of its primary key.
in ORM at line 790
static ORM
create(array $columns = [], bool $raw = false, bool $whitelist = true)
Creates a new record and returns the model.
in ORM at line 806
protected HasOne
hasOne(string $model, string|null $foreignKey = null)
Returns a HasOne relation.
in ORM at line 820
protected HasOnePolymorphic
hasOnePolymorphic(string $model, string $polymorphicType)
Returns a HasOnePolymorphic relation.
in ORM at line 834
protected HasMany
hasMany(string $model, string|null $foreignKey = null)
Returns a HasMany relation.
in ORM at line 848
protected HasManyPolymorphic
hasManyPolymorphic(string $model, string $polymorphicType)
Returns a HasManyPolymorphic relation.
in ORM at line 864
protected ManyToMany
manyToMany(string $model, string|null $foreignKey = null, string|null $junctionTable = null, string|null $junctionKey = null)
Returns a ManyToMany relation.
in ORM at line 878
protected BelongsTo
belongsTo(string $model, string|null $foreignKey = null)
Returns a BelongsTo relation.
in ORM at line 892
protected BelongsToPolymorphic
belongsToPolymorphic(string $model, string $polymorphicType)
Returns a BelongsToPolymorphic relation.
in ORM at line 904
bool
isModified()
Has the record been modified?
in ORM at line 914
array
getModified()
Returns the modified column values of the record.
in ORM at line 934
protected mixed
generatePrimaryKey()
Generates a primary key.
in ORM at line 984
bool
save()
Saves the record to the database.
in ORM at line 1029
bool
delete()
Deletes a record from the database.
in ORM at line 1055
$this
protect(string|array|bool $column)
Excludes the chosen columns and relations from array and json representations of the record.
You expose all fields by passing FALSE.
in ORM at line 1069
$this
expose(string|array|bool $column)
Exposes the chosen columns and relations in the array and json representations of the record.
You can expose all fields by passing TRUE.
in ORM at line 1081
array
toArray()
Returns an array representation of the record.
in ORM at line 1128
array
jsonSerialize()
Returns data which can be serialized by json_encode().
in ORM at line 1139
string
toJson(int $options = 0)
Returns a json representation of the record.
in ORM at line 1149
string
__toString()
Returns a json representation of the record.
in ORM at line 1161
mixed
__call(string $name, array $arguments)
Forwards method calls to the query builder.
in ORM at line 1173
static mixed
__callStatic(string $name, array $arguments)
Forwards static method calls to the query builder.
in AuthorizableTrait at line 31
setAuthorizer(AuthorizerInterface $authorizer)
Sets the authorizer.
in AuthorizableTrait at line 44
bool
can(string $action, object|string $entity, mixed ...$parameters)
Returns TRUE if allowed to perform the action on the entity and FALSE if not.
in TimestampedTrait at line 28
protected array
getTimestampedTraitHooks()
Returns trait hooks.
in TimestampedTrait at line 100
protected array
getTimestampedTraitCasts()
Returns trait casts.
in TimestampedTrait at line 110
protected bool
shouldTouchOnInsert()
Should we touch relations on insert?
in TimestampedTrait at line 120
protected bool
shouldTouchOnUpdate()
Should we touch relations on update?
in TimestampedTrait at line 130
protected bool
shouldTouchOnDelete()
Should we touch relations on delete?
in TimestampedTrait at line 140
string
getCreatedAtColumn()
Returns the column that holds the "created at" timestamp.
in TimestampedTrait at line 150
string
getUpdatedAtColumn()
Returns the column that holds the "updated at" timestamp.
in TimestampedTrait at line 160
protected array
getRelationsToTouch()
Returns the relations that we should touch.
in TimestampedTrait at line 170
bool
touch()
Allows you to update the "updated at" timestamp without modifying any data.
in TimestampedTrait at line 185
protected
touchRelated()
Touches related records.
at line 72
ManyToMany
groups()
User groups.
at line 82
protected HasherInterface
getHasher()
Returns a hasher instance.
at line 93
protected string
passwordMutator(string $password)
Password mutator.
at line 103
protected string
generateToken()
Generates a new token.
at line 48
int
getId()
at line 121
setEmail(string $email)
Sets the user email address.
at line 131
string
getEmail()
Returns the user email address.
at line 141
setUsername(string $username)
Sets the username.
at line 149
string
getUsername()
Returns the user username.
at line 159
setPassword(string $password)
Sets the user password.
at line 169
string
getPassword()
Returns the user password hash.
at line 179
setIp(string $ip)
Sets the user IP address.
at line 189
string
getIp()
Returns the user IP address.
at line 199
string
generateActionToken()
Generates a new action token.
at line 209
string
getActionToken()
Returns the user action token.
at line 219
string
generateAccessToken()
Generates a new access token.
at line 229
string
getAccessToken()
Returns the user access token.
at line 237
activate()
Activates the user.
at line 245
deactivate()
Deactivates the user.
at line 255
bool
isActivated()
Returns TRUE of the user is activated and FALSE if not.
at line 263
ban()
Bans the user.
at line 271
unban()
Unbans the user.
at line 281
bool
isBanned()
Returns TRUE if the user is banned and FALSE if not.
at line 293
bool
validatePassword(string $password, bool $autoSave = true)
Returns TRUE if the provided password is correct and FALSE if not.
at line 319
bool
isMemberOf(string|int|array $group)
Returns TRUE if a user is a member of the group(s) and FALSE if not.
at line 345
lockUntil(DateTimeInterface $time)
Locks the account until the given date.
at line 355
Time|DateTimeInterface|null
lockedUntil()
Returns null if the account isn't locked and a date time instance if its locked.
at line 363
unlock()
Unlocks the account.
at line 373
bool
isLocked()
Returns TRUE if the account is locked and FALSE if not.
at line 383
int
getFailedAttempts()
Returns the number of failed login attempts.
at line 393
Time|DateTimeInterface|null
getLastFailAt()
Gets the time of the last failed attempt.
at line 406
bool
throttle(int $maxLoginAttempts, int $lockTime, bool $autoSave = true)
Throttles login attempts.
at line 444
bool
resetThrottle(bool $autoSave = true)
Resets the login throttling.