User
class User extends Model implements Authenticatable, Authorizable, CanResetPassword (View source)
Traits
Constants
CREATED_AT |
The name of the "created at" column. |
UPDATED_AT |
The name of the "updated at" column. |
Properties
bool | $incrementing | Indicates if the IDs are auto-incrementing. | from Model |
bool | $timestamps | Indicates if the model should be timestamped. | from Model |
bool | $exists | Indicates if the model exists. | from Model |
bool | $wasRecentlyCreated | Indicates if the model was inserted during the current request lifecycle. | from Model |
static bool | $snakeAttributes | Indicates whether attributes are snake cased on arrays. | from Model |
static array | $manyMethods | The many to many relationship methods. | from Model |
Methods
Clear the list of booted models so they will be re-booted.
Register a new global scope on the model.
Register an observer with the Model.
Fill the model with an array of attributes. Force mass assignment.
Create a new instance of the given model.
Create a new model instance that is existing.
Create a collection of models from plain arrays.
Create a collection of models from a raw query.
Save a new model and return the instance.
Save a new model and return the instance. Allow mass-assignment.
Begin querying the model on a given connection.
Get all of the models from the database.
Reload a fresh model instance from the database.
Append attributes to query when building a query.
Define a one-to-one relationship.
Define a polymorphic one-to-one relationship.
Define an inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Retrieve the fully qualified class name from a slug.
Define a one-to-many relationship.
Define a has-many-through relationship.
Define a polymorphic one-to-many relationship.
Define a many-to-many relationship.
Define a polymorphic many-to-many relationship.
Define a polymorphic, inverse many-to-many relationship.
Get the joining table name for a many-to-many relation.
Register an updating model event with the dispatcher.
Register an updated model event with the dispatcher.
Register a creating model event with the dispatcher.
Register a created model event with the dispatcher.
Register a deleting model event with the dispatcher.
Register a deleted model event with the dispatcher.
Update the model in the database.
Save the model to the database using transaction.
Get a new query builder that doesn't have any global scopes.
Create a new Eloquent Collection instance.
Create a new pivot model instance.
Add hidden attributes for the model.
Make the given, typically hidden, attributes visible.
Make the given, typically hidden, attributes visible.
Add visible attributes for the model.
Run the given callable while being unguarded.
Set the relationships that are touched on save.
Determine whether an attribute should be cast to a native type.
Decode the given JSON back into an array or object.
Set the array of model attributes. No checking is done.
Get the model's original attribute values.
Sync a single original attribute with its current value.
Determine if the model or given attribute(s) have been modified.
Set the specific relationship in the model.
Resolve a connection instance.
Get the connection resolver instance.
Extract and cache all the mutated attributes of a class.
Handle dynamic method calls into the model.
Handle dynamic static method calls into the method.
Get the name of the unique identifier for the user.
Set the token value for the "remember me" session.
Determine if the entity has a given ability.
Determine if the entity does not have a given ability.
Determine if the entity does not have a given ability.
Get the e-mail address where password reset links are sent.
Details
static
mixed
addGlobalScope(
Scope|Closure|string $scope,
Closure $implementation = null)
Register a new global scope on the model.
static
Scope|Closure|null
getGlobalScope(
Scope|string $scope)
Get a global scope registered with the model.
$this
forceFill(
array $attributes)
Fill the model with an array of attributes. Force mass assignment.
Model
newInstance(
array $attributes = array(),
bool $exists = false)
Create a new instance of the given model.
Model
newFromBuilder(
array $attributes = array(),
string|null $connection = null)
Create a new model instance that is existing.
static
Collection
hydrate(
array $items,
string|null $connection = null)
Create a collection of models from plain arrays.
static
Collection
hydrateRaw(
string $query,
array $bindings = array(),
string|null $connection = null)
Create a collection of models from a raw query.
static
Model
forceCreate(
array $attributes)
Save a new model and return the instance. Allow mass-assignment.
static
Collection|Model[]
all(
array|mixed $columns = array('*'))
Get all of the models from the database.
HasOne
hasOne(
string $related,
string $foreignKey = null,
string $localKey = null)
Define a one-to-one relationship.
MorphOne
morphOne(
string $related,
string $name,
string $type = null,
string $id = null,
string $localKey = null)
Define a polymorphic one-to-one relationship.
BelongsTo
belongsTo(
string $related,
string $foreignKey = null,
string $otherKey = null,
string $relation = null)
Define an inverse one-to-one or many relationship.
MorphTo
morphTo(
string $name = null,
string $type = null,
string $id = null)
Define a polymorphic, inverse one-to-one or many relationship.
string
getActualClassNameForMorph(
string $class)
Retrieve the fully qualified class name from a slug.
HasMany
hasMany(
string $related,
string $foreignKey = null,
string $localKey = null)
Define a one-to-many relationship.
HasManyThrough
hasManyThrough(
string $related,
string $through,
string|null $firstKey = null,
string|null $secondKey = null,
string|null $localKey = null)
Define a has-many-through relationship.
MorphMany
morphMany(
string $related,
string $name,
string $type = null,
string $id = null,
string $localKey = null)
Define a polymorphic one-to-many relationship.
BelongsToMany
belongsToMany(
string $related,
string $table = null,
string $foreignKey = null,
string $otherKey = null,
string $relation = null)
Define a many-to-many relationship.
MorphToMany
morphToMany(
string $related,
string $name,
string $table = null,
string $foreignKey = null,
string $otherKey = null,
bool $inverse = false)
Define a polymorphic many-to-many relationship.
MorphToMany
morphedByMany(
string $related,
string $name,
string $table = null,
string $foreignKey = null,
string $otherKey = null)
Define a polymorphic, inverse many-to-many relationship.
bool|null
forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when trait is missing.
static
void
saving(
Closure|string $callback,
int $priority)
Register a saving model event with the dispatcher.
static
void
saved(
Closure|string $callback,
int $priority)
Register a saved model event with the dispatcher.
static
void
updating(
Closure|string $callback,
int $priority)
Register an updating model event with the dispatcher.
static
void
updated(
Closure|string $callback,
int $priority)
Register an updated model event with the dispatcher.
static
void
creating(
Closure|string $callback,
int $priority)
Register a creating model event with the dispatcher.
static
void
created(
Closure|string $callback,
int $priority)
Register a created model event with the dispatcher.
static
void
deleting(
Closure|string $callback,
int $priority)
Register a deleting model event with the dispatcher.
static
void
deleted(
Closure|string $callback,
int $priority)
Register a deleted model event with the dispatcher.
bool|int
update(
array $attributes = array(),
array $options = array())
Update the model in the database.
Builder|Model
newEloquentBuilder(
Builder $query)
Create a new Eloquent query builder for the model.
Pivot
newPivot(
Model $parent,
array $attributes,
string $table,
bool $exists)
Create a new pivot model instance.
bool
hasCast(
string $key,
array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
mixed
fromJson(
string $value,
bool $asObject = false)
Decode the given JSON back into an array or object.
$this
setRawAttributes(
array $attributes,
bool $sync = false)
Set the array of model attributes. No checking is done.
mixed|array
getOriginal(
string|null $key = null,
mixed $default = null)
Get the model's original attribute values.
$this
syncOriginalAttribute(
string $attribute)
Sync a single original attribute with its current value.
bool
isDirty(
array|string|null $attributes = null)
Determine if the model or given attribute(s) have been modified.
static
void
setConnectionResolver(
ConnectionResolverInterface $resolver)
Set the connection resolver instance.
static
void
cacheMutatedAttributes(
string $class)
Extract and cache all the mutated attributes of a class.
static
mixed
__callStatic(
string $method,
array $parameters)
Handle dynamic static method calls into the method.
in Authenticatable at line line 12
string
getAuthIdentifierName()
Get the name of the unique identifier for the user.
in Authenticatable at line line 22
mixed
getAuthIdentifier()
Get the unique identifier for the user.
in Authenticatable at line line 42
string
getRememberToken()
Get the token value for the "remember me" session.
in Authenticatable at line line 53
void
setRememberToken(
string $value)
Set the token value for the "remember me" session.
in Authenticatable at line line 63
string
getRememberTokenName()
Get the column name for the "remember me" token.
in Authorizable at line line 16
bool
can(
string $ability,
array|mixed $arguments = array())
Determine if the entity has a given ability.
in Authorizable at line line 28
bool
cant(
string $ability,
array|mixed $arguments = array())
Determine if the entity does not have a given ability.
in Authorizable at line line 40
bool
cannot(
string $ability,
array|mixed $arguments = array())
Determine if the entity does not have a given ability.
in CanResetPassword at line line 12
string
getEmailForPasswordReset()
Get the e-mail address where password reset links are sent.