User class User extends Model implements Authenticatable, Authorizable, CanResetPassword (View source) Traits Authenticatable Authorizable CanResetPassword MustVerifyEmail HasAttributes HasEvents HasGlobalScopes HasRelationships HasTimestamps HidesAttributes GuardsAttributes ForwardsCalls Constants CREATED_AT The name of the "created at" column. UPDATED_AT The name of the "updated at" column. Properties protected array $attributes The model's attributes. from HasAttributes protected array $original The model attribute's original state. from HasAttributes protected array $changes The changed model attributes. from HasAttributes protected array $casts The attributes that should be cast. from HasAttributes protected array $classCastCache The attributes that have been cast using custom classes. from HasAttributes static protected string[] $primitiveCastTypes The built-in, primitive cast types supported by Eloquent. from HasAttributes protected array $dates The attributes that should be mutated to dates. from HasAttributes protected string $dateFormat The storage format of the model's date columns. from HasAttributes protected array $appends The accessors to append to the model's array form. from HasAttributes static bool $snakeAttributes Indicates whether attributes are snake cased on arrays. from HasAttributes static protected array $mutatorCache The cache of the mutated attributes for each class. from HasAttributes static Encrypter $encrypter The encrypter instance that is used to encrypt attributes. from HasAttributes protected array $dispatchesEvents The event map for the model. from HasEvents protected array $observables User exposed observable events. from HasEvents protected array $relations The loaded relationships for the model. from HasRelationships protected array $touches The relationships that should be touched on save. from HasRelationships static string[] $manyMethods The many to many relationship methods. from HasRelationships static protected array $relationResolvers The relation resolver callbacks. from HasRelationships bool $timestamps Indicates if the model should be timestamped. from HasTimestamps protected array $hidden The attributes that should be hidden for serialization. from HidesAttributes protected array $visible The attributes that should be visible in serialization. from HidesAttributes protected string[] $fillable The attributes that are mass assignable. from GuardsAttributes protected string[]|bool $guarded The attributes that aren't mass assignable. from GuardsAttributes static protected bool $unguarded Indicates if all mass assignment is enabled. from GuardsAttributes static protected array $guardableColumns The actual columns that exist on the database and can be guarded. from GuardsAttributes protected string|null $connection The connection name for the model. from Model protected string $table The table associated with the model. from Model protected string $primaryKey The primary key for the model. from Model protected string $keyType The "type" of the primary key ID. from Model bool $incrementing Indicates if the IDs are auto-incrementing. from Model protected array $with The relations to eager load on every query. from Model protected array $withCount The relationship counts that should be eager loaded on every query. from Model protected int $perPage The number of models to return for pagination. 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 protected ConnectionResolverInterface $resolver The connection resolver instance. from Model static protected Dispatcher $dispatcher The event dispatcher instance. from Model static protected array $booted The array of booted models. from Model static protected array $traitInitializers The array of trait initializers that will be called on each new instance. from Model static protected array $globalScopes The array of global scopes on the model. from Model static protected array $ignoreOnTouch The list of models classes that should not be affected with touch. from Model protected string $rememberTokenName The column name of the "remember me" token. from Authenticatable Methods array attributesToArray() Convert the model's attributes to an array. from HasAttributes array addDateAttributesToArray(array $attributes) Add the date attributes to the attributes array. from HasAttributes array addMutatedAttributesToArray(array $attributes, array $mutatedAttributes) Add the mutated attributes to the attributes array. from HasAttributes array addCastAttributesToArray(array $attributes, array $mutatedAttributes) Add the casted attributes to the attributes array. from HasAttributes array getArrayableAttributes() Get an attribute array of all arrayable attributes. from HasAttributes array getArrayableAppends() Get all of the appendable values that are arrayable. from HasAttributes array relationsToArray() Get the model's relationships in array form. from HasAttributes array getArrayableRelations() Get an attribute array of all arrayable relations. from HasAttributes array getArrayableItems(array $values) Get an attribute array of all arrayable values. from HasAttributes mixed getAttribute(string $key) Get an attribute from the model. from HasAttributes mixed getAttributeValue(string $key) Get a plain attribute (not a relationship). from HasAttributes mixed getAttributeFromArray(string $key) Get an attribute from the $attributes array. from HasAttributes mixed getRelationValue(string $key) Get a relationship. from HasAttributes mixed getRelationshipFromMethod(string $method) Get a relationship value from a method. from HasAttributes bool hasGetMutator(string $key) Determine if a get mutator exists for an attribute. from HasAttributes mixed mutateAttribute(string $key, mixed $value) Get the value of an attribute using its mutator. from HasAttributes mixed mutateAttributeForArray(string $key, mixed $value) Get the value of an attribute using its mutator for array conversion. from HasAttributes void mergeCasts(array $casts) Merge new casts with existing casts on the model. from HasAttributes mixed castAttribute(string $key, mixed $value) Cast an attribute to a native PHP type. from HasAttributes mixed getClassCastableAttributeValue(string $key, mixed $value) Cast the given attribute using a custom cast class. from HasAttributes string getCastType(string $key) Get the type of cast for a model attribute. from HasAttributes mixed deviateClassCastableAttribute(string $method, string $key, mixed $value) Increment or decrement the given attribute using the custom cast class. from HasAttributes mixed serializeClassCastableAttribute(string $key, mixed $value) Serialize the given attribute using the custom cast class. from HasAttributes bool isCustomDateTimeCast(string $cast) Determine if the cast type is a custom date time cast. from HasAttributes bool isDecimalCast(string $cast) Determine if the cast type is a decimal cast. from HasAttributes mixed setAttribute(string $key, mixed $value) Set a given attribute on the model. from HasAttributes bool hasSetMutator(string $key) Determine if a set mutator exists for an attribute. from HasAttributes mixed setMutatedAttributeValue(string $key, mixed $value) Set the value of an attribute using its mutator. from HasAttributes bool isDateAttribute(string $key) Determine if the given attribute is a date or date castable. from HasAttributes $this fillJsonAttribute(string $key, mixed $value) Set a given JSON attribute on the model. from HasAttributes void setClassCastableAttribute(string $key, mixed $value) Set the value of a class castable attribute. from HasAttributes $this getArrayAttributeWithValue(string $path, string $key, mixed $value) Get an array attribute with the given key and value set. from HasAttributes array getArrayAttributeByKey(string $key) Get an array attribute or return an empty array if it is not set. from HasAttributes string castAttributeAsJson(string $key, mixed $value) Cast the given attribute to JSON. from HasAttributes string asJson(mixed $value) Encode the given value as JSON. from HasAttributes mixed fromJson(string $value, bool $asObject = false) Decode the given JSON back into an array or object. from HasAttributes mixed fromEncryptedString(string $value) Decrypt the given encrypted string. from HasAttributes string castAttributeAsEncryptedString(string $key, mixed $value) Cast the given attribute to an encrypted string. from HasAttributes static void encryptUsing(Encrypter $encrypter) Set the encrypter instance that will be used to encrypt attributes. from HasAttributes mixed fromFloat(mixed $value) Decode the given float. from HasAttributes string asDecimal(float $value, int $decimals) Return a decimal as string. from HasAttributes Carbon asDate(mixed $value) Return a timestamp as DateTime object with time set to 00:00:00. from HasAttributes Carbon asDateTime(mixed $value) Return a timestamp as DateTime object. from HasAttributes bool isStandardDateFormat(string $value) Determine if the given value is a standard date format. from HasAttributes string|null fromDateTime(mixed $value) Convert a DateTime to a storable string. from HasAttributes int asTimestamp(mixed $value) Return a timestamp as unix timestamp. from HasAttributes string serializeDate(DateTimeInterface $date) Prepare a date for array / JSON serialization. from HasAttributes array getDates() Get the attributes that should be converted to dates. from HasAttributes string getDateFormat() Get the format for database stored dates. from HasAttributes $this setDateFormat(string $format) Set the date format used by the model. from HasAttributes bool hasCast(string $key, array|string|null $types = null) Determine whether an attribute should be cast to a native type. from HasAttributes array getCasts() Get the casts array. from HasAttributes bool isDateCastable(string $key) Determine whether a value is Date / DateTime castable for inbound manipulation. from HasAttributes bool isJsonCastable(string $key) Determine whether a value is JSON castable for inbound manipulation. from HasAttributes bool isEncryptedCastable(string $key) Determine whether a value is an encrypted castable for inbound manipulation. from HasAttributes bool isClassCastable(string $key) Determine if the given key is cast using a custom class. from HasAttributes bool isClassDeviable(string $key) Determine if the key is deviable using a custom class. from HasAttributes bool isClassSerializable(string $key) Determine if the key is serializable using a custom class. from HasAttributes mixed resolveCasterClass(string $key) Resolve the custom caster class for a given key. from HasAttributes string parseCasterClass(string $class) Parse the given caster class, removing any arguments. from HasAttributes void mergeAttributesFromClassCasts() Merge the cast class attributes back into the model. from HasAttributes array normalizeCastClassResponse(string $key, mixed $value) Normalize the response from a custom class caster. from HasAttributes array getAttributes() Get all of the current attributes on the model. from HasAttributes $this setRawAttributes(array $attributes, bool $sync = false) Set the array of model attributes. No checking is done. from HasAttributes mixed|array getOriginal(string|null $key = null, mixed $default = null) Get the model's original attribute values. from HasAttributes mixed|array getOriginalWithoutRewindingModel(string|null $key = null, mixed $default = null) Get the model's original attribute values. from HasAttributes mixed|array getRawOriginal(string|null $key = null, mixed $default = null) Get the model's raw original attribute values. from HasAttributes array only(array|mixed $attributes) Get a subset of the model's attributes. from HasAttributes $this syncOriginal() Sync the original attributes with the current. from HasAttributes $this syncOriginalAttribute(string $attribute) Sync a single original attribute with its current value. from HasAttributes $this syncOriginalAttributes(array|string $attributes) Sync multiple original attribute with their current values. from HasAttributes $this syncChanges() Sync the changed attributes. from HasAttributes bool isDirty(array|string|null $attributes = null) Determine if the model or any of the given attribute(s) have been modified. from HasAttributes bool isClean(array|string|null $attributes = null) Determine if the model and all the given attribute(s) have remained the same. from HasAttributes bool wasChanged(array|string|null $attributes = null) Determine if the model or any of the given attribute(s) have been modified. from HasAttributes bool hasChanges(array $changes, array|string|null $attributes = null) Determine if any of the given attributes were changed. from HasAttributes array getDirty() Get the attributes that have been changed since last sync. from HasAttributes array getChanges() Get the attributes that were changed. from HasAttributes bool originalIsEquivalent(string $key) Determine if the new and old values for a given key are equivalent. from HasAttributes mixed transformModelValue(string $key, mixed $value) Transform a raw model value using mutators, casts, etc. from HasAttributes $this append(array|string $attributes) Append attributes to query when building a query. from HasAttributes $this setAppends(array $appends) Set the accessors to append to model arrays. from HasAttributes bool hasAppended(string $attribute) Return whether the accessor attribute has been appended. from HasAttributes array getMutatedAttributes() Get the mutated attributes for a given instance. from HasAttributes static void cacheMutatedAttributes(string $class) Extract and cache all the mutated attributes of a class. from HasAttributes static array getMutatorMethods(mixed $class) Get all of the attribute mutator methods. from HasAttributes static void observe(object|array|string $classes) Register observers with the model. from HasEvents void registerObserver(object|string $class) Register a single observer with the model. from HasEvents array getObservableEvents() Get the observable event names. from HasEvents $this setObservableEvents(array $observables) Set the observable event names. from HasEvents void addObservableEvents(array|mixed $observables) Add an observable event name. from HasEvents void removeObservableEvents(array|mixed $observables) Remove an observable event name. from HasEvents static void registerModelEvent(string $event, Closure|string $callback) Register a model event with the dispatcher. from HasEvents mixed fireModelEvent(string $event, bool $halt = true) Fire the given event for the model. from HasEvents mixed|null fireCustomModelEvent(string $event, string $method) Fire a custom model event for the given event. from HasEvents mixed filterModelEventResults(mixed $result) Filter the model event results. from HasEvents static void retrieved(Closure|string $callback) Register a retrieved model event with the dispatcher. from HasEvents static void saving(Closure|string $callback) Register a saving model event with the dispatcher. from HasEvents static void saved(Closure|string $callback) Register a saved model event with the dispatcher. from HasEvents static void updating(Closure|string $callback) Register an updating model event with the dispatcher. from HasEvents static void updated(Closure|string $callback) Register an updated model event with the dispatcher. from HasEvents static void creating(Closure|string $callback) Register a creating model event with the dispatcher. from HasEvents static void created(Closure|string $callback) Register a created model event with the dispatcher. from HasEvents static void replicating(Closure|string $callback) Register a replicating model event with the dispatcher. from HasEvents static void deleting(Closure|string $callback) Register a deleting model event with the dispatcher. from HasEvents static void deleted(Closure|string $callback) Register a deleted model event with the dispatcher. from HasEvents static void flushEventListeners() Remove all of the event listeners for the model. from HasEvents static Dispatcher getEventDispatcher() Get the event dispatcher instance. from HasEvents static void setEventDispatcher(Dispatcher $dispatcher) Set the event dispatcher instance. from HasEvents static void unsetEventDispatcher() Unset the event dispatcher for models. from HasEvents static mixed withoutEvents(callable $callback) Execute a callback without firing any model events for any model type. from HasEvents static mixed addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null) Register a new global scope on the model. from HasGlobalScopes static bool hasGlobalScope(Scope|string $scope) Determine if a model has a global scope. from HasGlobalScopes static Scope|Closure|null getGlobalScope(Scope|string $scope) Get a global scope registered with the model. from HasGlobalScopes array getGlobalScopes() Get the global scopes for this class instance. from HasGlobalScopes static void resolveRelationUsing(string $name, Closure $callback) Define a dynamic relation resolver. from HasRelationships HasOne hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null) Define a one-to-one relationship. from HasRelationships HasOne newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey) Instantiate a new HasOne relationship. from HasRelationships HasOneThrough hasOneThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null) Define a has-one-through relationship. from HasRelationships HasOneThrough newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey) Instantiate a new HasOneThrough relationship. from HasRelationships MorphOne morphOne(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null) Define a polymorphic one-to-one relationship. from HasRelationships MorphOne newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey) Instantiate a new MorphOne relationship. from HasRelationships BelongsTo belongsTo(string $related, string|null $foreignKey = null, string|null $ownerKey = null, string|null $relation = null) Define an inverse one-to-one or many relationship. from HasRelationships BelongsTo newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation) Instantiate a new BelongsTo relationship. from HasRelationships MorphTo morphTo(string|null $name = null, string|null $type = null, string|null $id = null, string|null $ownerKey = null) Define a polymorphic, inverse one-to-one or many relationship. from HasRelationships MorphTo morphEagerTo(string $name, string $type, string $id, string $ownerKey) Define a polymorphic, inverse one-to-one or many relationship. from HasRelationships MorphTo morphInstanceTo(string $target, string $name, string $type, string $id, string $ownerKey) Define a polymorphic, inverse one-to-one or many relationship. from HasRelationships MorphTo newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation) Instantiate a new MorphTo relationship. from HasRelationships static string getActualClassNameForMorph(string $class) Retrieve the actual class name for a given morph class. from HasRelationships string guessBelongsToRelation() Guess the "belongs to" relationship name. from HasRelationships HasMany hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null) Define a one-to-many relationship. from HasRelationships HasMany newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey) Instantiate a new HasMany relationship. from HasRelationships HasManyThrough hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null) Define a has-many-through relationship. from HasRelationships HasManyThrough newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey) Instantiate a new HasManyThrough relationship. from HasRelationships MorphMany morphMany(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null) Define a polymorphic one-to-many relationship. from HasRelationships MorphMany newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey) Instantiate a new MorphMany relationship. from HasRelationships BelongsToMany belongsToMany(string $related, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, string|null $relation = null) Define a many-to-many relationship. from HasRelationships BelongsToMany newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null) Instantiate a new BelongsToMany relationship. from HasRelationships MorphToMany morphToMany(string $related, string $name, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, bool $inverse = false) Define a polymorphic many-to-many relationship. from HasRelationships MorphToMany newMorphToMany(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null, bool $inverse = false) Instantiate a new MorphToMany relationship. from HasRelationships MorphToMany morphedByMany(string $related, string $name, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null) Define a polymorphic, inverse many-to-many relationship. from HasRelationships string|null guessBelongsToManyRelation() Get the relationship name of the belongsToMany relationship. from HasRelationships string joiningTable(string $related, Model|null $instance = null) Get the joining table name for a many-to-many relation. from HasRelationships string joiningTableSegment() Get this model's half of the intermediate table name for belongsToMany relationships. from HasRelationships bool touches(string $relation) Determine if the model touches a given relation. from HasRelationships void touchOwners() Touch the owning relations of the model. from HasRelationships array getMorphs(string $name, string $type, string $id) Get the polymorphic relationship columns. from HasRelationships string getMorphClass() Get the class name for polymorphic relations. from HasRelationships mixed newRelatedInstance(string $class) Create a new model instance for a related model. from HasRelationships array getRelations() Get all the loaded relations for the instance. from HasRelationships mixed getRelation(string $relation) Get a specified relationship. from HasRelationships bool relationLoaded(string $key) Determine if the given relation is loaded. from HasRelationships $this setRelation(string $relation, mixed $value) Set the given relationship on the model. from HasRelationships $this unsetRelation(string $relation) Unset a loaded relationship. from HasRelationships $this setRelations(array $relations) Set the entire relations array on the model. from HasRelationships $this withoutRelations() Duplicate the instance and unset all the loaded relations. from HasRelationships $this unsetRelations() Unset all the loaded relations for the instance. from HasRelationships array getTouchedRelations() Get the relationships that are touched on save. from HasRelationships $this setTouchedRelations(array $touches) Set the relationships that are touched on save. from HasRelationships bool touch() Update the model's update timestamp. from HasTimestamps void updateTimestamps() Update the creation and update timestamps. from HasTimestamps $this setCreatedAt(mixed $value) Set the value of the "created at" attribute. from HasTimestamps $this setUpdatedAt(mixed $value) Set the value of the "updated at" attribute. from HasTimestamps Carbon freshTimestamp() Get a fresh timestamp for the model. from HasTimestamps string freshTimestampString() Get a fresh timestamp for the model. from HasTimestamps bool usesTimestamps() Determine if the model uses timestamps. from HasTimestamps string|null getCreatedAtColumn() Get the name of the "created at" column. from HasTimestamps string|null getUpdatedAtColumn() Get the name of the "updated at" column. from HasTimestamps string getQualifiedCreatedAtColumn() Get the fully qualified "created at" column. from HasTimestamps string getQualifiedUpdatedAtColumn() Get the fully qualified "updated at" column. from HasTimestamps array getHidden() Get the hidden attributes for the model. from HidesAttributes $this setHidden(array $hidden) Set the hidden attributes for the model. from HidesAttributes array getVisible() Get the visible attributes for the model. from HidesAttributes $this setVisible(array $visible) Set the visible attributes for the model. from HidesAttributes $this makeVisible(array|string|null $attributes) Make the given, typically hidden, attributes visible. from HidesAttributes $this makeVisibleIf(bool|Closure $condition, array|string|null $attributes) Make the given, typically hidden, attributes visible if the given truth test passes. from HidesAttributes $this makeHidden(array|string|null $attributes) Make the given, typically visible, attributes hidden. from HidesAttributes $this makeHiddenIf(bool|Closure $condition, array|string|null $attributes) Make the given, typically visible, attributes hidden if the given truth test passes. from HidesAttributes array getFillable() Get the fillable attributes for the model. from GuardsAttributes $this fillable(array $fillable) Set the fillable attributes for the model. from GuardsAttributes $this mergeFillable(array $fillable) Merge new fillable attributes with existing fillable attributes on the model. from GuardsAttributes array getGuarded() Get the guarded attributes for the model. from GuardsAttributes $this guard(array $guarded) Set the guarded attributes for the model. from GuardsAttributes $this mergeGuarded(array $guarded) Merge new guarded attributes with existing guarded attributes on the model. from GuardsAttributes static void unguard(bool $state = true) Disable all mass assignable restrictions. from GuardsAttributes static void reguard() Enable the mass assignment restrictions. from GuardsAttributes static bool isUnguarded() Determine if current state is "unguarded". from GuardsAttributes static mixed unguarded(callable $callback) Run the given callable while being unguarded. from GuardsAttributes bool isFillable(string $key) Determine if the given attribute may be mass assigned. from GuardsAttributes bool isGuarded(string $key) Determine if the given key is guarded. from GuardsAttributes bool isGuardableColumn(string $key) Determine if the given column is a valid, guardable column. from GuardsAttributes bool totallyGuarded() Determine if the model is totally guarded. from GuardsAttributes array fillableFromArray(array $attributes) Get the fillable attributes of a given array. from GuardsAttributes mixed forwardCallTo(mixed $object, string $method, array $parameters) Forward a method call to the given object. from ForwardsCalls static void throwBadMethodCallException(string $method) Throw a bad method call exception for the given method. from ForwardsCalls void __construct(array $attributes = []) Create a new Eloquent model instance. from Model void bootIfNotBooted() Check if the model needs to be booted and if so, do it. from Model static void booting() Perform any actions required before the model boots. from Model static void boot() Bootstrap the model and its traits. from Model static void bootTraits() Boot all of the bootable traits on the model. from Model void initializeTraits() Initialize any initializable traits on the model. from Model static void booted() Perform any actions required after the model boots. from Model static void clearBootedModels() Clear the list of booted models so they will be re-booted. from Model static void withoutTouching(callable $callback) Disables relationship model touching for the current class during given callback scope. from Model static void withoutTouchingOn(array $models, callable $callback) Disables relationship model touching for the given model classes during given callback scope. from Model static bool isIgnoringTouch(string|null $class = null) Determine if the given model is ignoring touches. from Model $this fill(array $attributes) Fill the model with an array of attributes. from Model $this forceFill(array $attributes) Fill the model with an array of attributes. Force mass assignment. from Model string qualifyColumn(string $column) Qualify the given column name by the model's table. from Model Model newInstance(array $attributes = [], bool $exists = false) Create a new instance of the given model. from Model Model newFromBuilder(array $attributes = [], string|null $connection = null) Create a new model instance that is existing. from Model static Builder on(string|null $connection = null) Begin querying the model on a given connection. from Model static Builder onWriteConnection() Begin querying the model on the write connection. from Model static Collection|Model[] all(array|mixed $columns = ['*']) Get all of the models from the database. from Model static Builder with(array|string $relations) Begin querying a model with eager loading. from Model $this load(array|string $relations) Eager load relations on the model. from Model $this loadMorph(string $relation, array $relations) Eager load relationships on the polymorphic relation of a model. from Model $this loadMissing(array|string $relations) Eager load relations on the model if they are not already eager loaded. from Model $this loadAggregate(array|string $relations, string $column, string $function = null) Eager load relation's column aggregations on the model. from Model $this loadCount(array|string $relations) Eager load relation counts on the model. from Model $this loadMax(array|string $relations, string $column) Eager load relation max column values on the model. from Model $this loadMin(array|string $relations, string $column) Eager load relation min column values on the model. from Model $this loadSum(array|string $relations, string $column) Eager load relation's column summations on the model. from Model $this loadAvg(array|string $relations, string $column) Eager load relation average column values on the model. from Model $this loadMorphAggregate(string $relation, array $relations, string $column, string $function = null) Eager load relationship column aggregation on the polymorphic relation of a model. from Model $this loadMorphCount(string $relation, array $relations) Eager load relationship counts on the polymorphic relation of a model. from Model $this loadMorphMax(string $relation, array $relations, string $column) Eager load relationship max column values on the polymorphic relation of a model. from Model $this loadMorphMin(string $relation, array $relations, string $column) Eager load relationship min column values on the polymorphic relation of a model. from Model $this loadMorphSum(string $relation, array $relations, string $column) Eager load relationship column summations on the polymorphic relation of a model. from Model $this loadMorphAvg(string $relation, array $relations, string $column) Eager load relationship average column values on the polymorphic relation of a model. from Model int increment(string $column, float|int $amount = 1, array $extra = []) Increment a column's value by a given amount. from Model int decrement(string $column, float|int $amount = 1, array $extra = []) Decrement a column's value by a given amount. from Model int incrementOrDecrement(string $column, float|int $amount, array $extra, string $method) Run the increment or decrement method on the model. from Model bool update(array $attributes = [], array $options = []) Update the model in the database. from Model bool push() Save the model and all of its relationships. from Model bool saveQuietly(array $options = []) Save the model to the database without raising any events. from Model bool save(array $options = []) Save the model to the database. from Model bool saveOrFail(array $options = []) Save the model to the database using transaction. from Model void finishSave(array $options) Perform any actions that are necessary after the model is saved. from Model bool performUpdate(Builder $query) Perform a model update operation. from Model Builder setKeysForSelectQuery(Builder $query) Set the keys for a select query. from Model mixed getKeyForSelectQuery() Get the primary key value for a select query. from Model Builder setKeysForSaveQuery(Builder $query) Set the keys for a save update query. from Model mixed getKeyForSaveQuery() Get the primary key value for a save query. from Model bool performInsert(Builder $query) Perform a model insert operation. from Model void insertAndSetId(Builder $query, array $attributes) Insert the given attributes and set the ID on the model. from Model static int destroy(Collection|array|int|string $ids) Destroy the models for the given IDs. from Model bool|null delete() Delete the model from the database. from Model bool|null forceDelete() Force a hard delete on a soft deleted model. from Model void performDeleteOnModel() Perform the actual delete query on this model instance. from Model static Builder query() Begin querying the model. from Model Builder newQuery() Get a new query builder for the model's table. from Model Builder|Model newModelQuery() Get a new query builder that doesn't have any global scopes or eager loading. from Model Builder newQueryWithoutRelationships() Get a new query builder with no relationships loaded. from Model Builder registerGlobalScopes(Builder $builder) Register the global scopes for this builder instance. from Model Builder|Model newQueryWithoutScopes() Get a new query builder that doesn't have any global scopes. from Model Builder newQueryWithoutScope(Scope|string $scope) Get a new query instance without a given scope. from Model Builder newQueryForRestoration(array|int $ids) Get a new query to restore one or more models by their queueable IDs. from Model Builder|Model newEloquentBuilder(Builder $query) Create a new Eloquent query builder for the model. from Model Builder newBaseQueryBuilder() Get a new query builder instance for the connection. from Model Collection newCollection(array $models = []) Create a new Eloquent Collection instance. from Model Pivot newPivot(Model $parent, array $attributes, string $table, bool $exists, string|null $using = null) Create a new pivot model instance. from Model bool hasNamedScope(string $scope) Determine if the model has a given scope. from Model mixed callNamedScope(string $scope, array $parameters = []) Apply the given named scope if possible. from Model array toArray() Convert the model instance to an array. from Model string toJson(int $options = 0) Convert the model instance to JSON. from Model array jsonSerialize() Convert the object into something JSON serializable. from Model Model|null fresh(array|string $with = []) Reload a fresh model instance from the database. from Model $this refresh() Reload the current model instance with fresh attributes from the database. from Model Model replicate(array $except = null) Clone the model into a new, non-existing instance. from Model bool is(Model|null $model) Determine if two models have the same ID and belong to the same table. from Model bool isNot(Model|null $model) Determine if two models are not the same. from Model Connection getConnection() Get the database connection for the model. from Model string|null getConnectionName() Get the current connection name for the model. from Model $this setConnection(string|null $name) Set the connection associated with the model. from Model static Connection resolveConnection(string|null $connection = null) Resolve a connection instance. from Model static ConnectionResolverInterface getConnectionResolver() Get the connection resolver instance. from Model static void setConnectionResolver(ConnectionResolverInterface $resolver) Set the connection resolver instance. from Model static void unsetConnectionResolver() Unset the connection resolver for models. from Model string getTable() Get the table associated with the model. from Model $this setTable(string $table) Set the table associated with the model. from Model string getKeyName() Get the primary key for the model. from Model $this setKeyName(string $key) Set the primary key for the model. from Model string getQualifiedKeyName() Get the table qualified key name. from Model string getKeyType() Get the auto-incrementing key type. from Model $this setKeyType(string $type) Set the data type for the primary key. from Model bool getIncrementing() Get the value indicating whether the IDs are incrementing. from Model $this setIncrementing(bool $value) Set whether IDs are incrementing. from Model mixed getKey() Get the value of the model's primary key. from Model mixed getQueueableId() Get the queueable identity for the entity. from Model array getQueueableRelations() Get the queueable relationships for the entity. from Model string|null getQueueableConnection() Get the queueable connection for the entity. from Model mixed getRouteKey() Get the value of the model's route key. from Model string getRouteKeyName() Get the route key for the model. from Model Model|null resolveRouteBinding(mixed $value, string|null $field = null) Retrieve the model for a bound value. from Model Model|null resolveChildRouteBinding(string $childType, mixed $value, string|null $field) Retrieve the child model for a bound value. from Model string getForeignKey() Get the default foreign key name for the model. from Model int getPerPage() Get the number of models to return per page. from Model $this setPerPage(int $perPage) Set the number of models to return per page. from Model mixed __get(string $key) Dynamically retrieve attributes on the model. from Model void __set(string $key, mixed $value) Dynamically set attributes on the model. from Model bool offsetExists(mixed $offset) Determine if the given attribute exists. from Model mixed offsetGet(mixed $offset) Get the value for a given offset. from Model void offsetSet(mixed $offset, mixed $value) Set the value for a given offset. from Model void offsetUnset(mixed $offset) Unset the value for a given offset. from Model bool __isset(string $key) Determine if an attribute or relation exists on the model. from Model void __unset(string $key) Unset an attribute on the model. from Model mixed __call(string $method, array $parameters) Handle dynamic method calls into the model. from Model static mixed __callStatic(string $method, array $parameters) Handle dynamic static method calls into the model. from Model string __toString() Convert the model to its string representation. from Model array __sleep() Prepare the object for serialization. from Model void __wakeup() When a model is being unserialized, check if it needs to be booted. from Model string getAuthIdentifierName() Get the name of the unique identifier for the user. from Authenticatable mixed getAuthIdentifier() Get the unique identifier for the user. from Authenticatable string getAuthPassword() Get the password for the user. from Authenticatable string|null getRememberToken() Get the token value for the "remember me" session. from Authenticatable void setRememberToken(string $value) Set the token value for the "remember me" session. from Authenticatable string getRememberTokenName() Get the column name for the "remember me" token. from Authenticatable bool can(iterable|string $abilities, array|mixed $arguments = []) Determine if the entity has the given abilities. from Authorizable bool canAny(iterable|string $abilities, array|mixed $arguments = []) Determine if the entity has any of the given abilities. from Authorizable bool cant(iterable|string $abilities, array|mixed $arguments = []) Determine if the entity does not have the given abilities. from Authorizable bool cannot(iterable|string $abilities, array|mixed $arguments = []) Determine if the entity does not have the given abilities. from Authorizable string getEmailForPasswordReset() Get the e-mail address where password reset links are sent. from CanResetPassword void sendPasswordResetNotification(string $token) Send the password reset notification. from CanResetPassword bool hasVerifiedEmail() Determine if the user has verified their email address. from MustVerifyEmail bool markEmailAsVerified() Mark the given user's email as verified. from MustVerifyEmail void sendEmailVerificationNotification() Send the email verification notification. from MustVerifyEmail string getEmailForVerification() Get the email address that should be used for verification. from MustVerifyEmail Details array attributesToArray() Convert the model's attributes to an array. Return Value array protected array addDateAttributesToArray(array $attributes) Add the date attributes to the attributes array. Parameters array $attributes Return Value array protected array addMutatedAttributesToArray(array $attributes, array $mutatedAttributes) Add the mutated attributes to the attributes array. Parameters array $attributes array $mutatedAttributes Return Value array protected array addCastAttributesToArray(array $attributes, array $mutatedAttributes) Add the casted attributes to the attributes array. Parameters array $attributes array $mutatedAttributes Return Value array protected array getArrayableAttributes() Get an attribute array of all arrayable attributes. Return Value array protected array getArrayableAppends() Get all of the appendable values that are arrayable. Return Value array array relationsToArray() Get the model's relationships in array form. Return Value array protected array getArrayableRelations() Get an attribute array of all arrayable relations. Return Value array protected array getArrayableItems(array $values) Get an attribute array of all arrayable values. Parameters array $values Return Value array mixed getAttribute(string $key) Get an attribute from the model. Parameters string $key Return Value mixed mixed getAttributeValue(string $key) Get a plain attribute (not a relationship). Parameters string $key Return Value mixed protected mixed getAttributeFromArray(string $key) Get an attribute from the $attributes array. Parameters string $key Return Value mixed mixed getRelationValue(string $key) Get a relationship. Parameters string $key Return Value mixed protected mixed getRelationshipFromMethod(string $method) Get a relationship value from a method. Parameters string $method Return Value mixed Exceptions LogicException bool hasGetMutator(string $key) Determine if a get mutator exists for an attribute. Parameters string $key Return Value bool protected mixed mutateAttribute(string $key, mixed $value) Get the value of an attribute using its mutator. Parameters string $key mixed $value Return Value mixed protected mixed mutateAttributeForArray(string $key, mixed $value) Get the value of an attribute using its mutator for array conversion. Parameters string $key mixed $value Return Value mixed void mergeCasts(array $casts) Merge new casts with existing casts on the model. Parameters array $casts Return Value void protected mixed castAttribute(string $key, mixed $value) Cast an attribute to a native PHP type. Parameters string $key mixed $value Return Value mixed protected mixed getClassCastableAttributeValue(string $key, mixed $value) Cast the given attribute using a custom cast class. Parameters string $key mixed $value Return Value mixed protected string getCastType(string $key) Get the type of cast for a model attribute. Parameters string $key Return Value string protected mixed deviateClassCastableAttribute(string $method, string $key, mixed $value) Increment or decrement the given attribute using the custom cast class. Parameters string $method string $key mixed $value Return Value mixed protected mixed serializeClassCastableAttribute(string $key, mixed $value) Serialize the given attribute using the custom cast class. Parameters string $key mixed $value Return Value mixed protected bool isCustomDateTimeCast(string $cast) Determine if the cast type is a custom date time cast. Parameters string $cast Return Value bool protected bool isDecimalCast(string $cast) Determine if the cast type is a decimal cast. Parameters string $cast Return Value bool mixed setAttribute(string $key, mixed $value) Set a given attribute on the model. Parameters string $key mixed $value Return Value mixed bool hasSetMutator(string $key) Determine if a set mutator exists for an attribute. Parameters string $key Return Value bool protected mixed setMutatedAttributeValue(string $key, mixed $value) Set the value of an attribute using its mutator. Parameters string $key mixed $value Return Value mixed protected bool isDateAttribute(string $key) Determine if the given attribute is a date or date castable. Parameters string $key Return Value bool $this fillJsonAttribute(string $key, mixed $value) Set a given JSON attribute on the model. Parameters string $key mixed $value Return Value $this protected void setClassCastableAttribute(string $key, mixed $value) Set the value of a class castable attribute. Parameters string $key mixed $value Return Value void protected $this getArrayAttributeWithValue(string $path, string $key, mixed $value) Get an array attribute with the given key and value set. Parameters string $path string $key mixed $value Return Value $this protected array getArrayAttributeByKey(string $key) Get an array attribute or return an empty array if it is not set. Parameters string $key Return Value array protected string castAttributeAsJson(string $key, mixed $value) Cast the given attribute to JSON. Parameters string $key mixed $value Return Value string protected string asJson(mixed $value) Encode the given value as JSON. Parameters mixed $value Return Value string mixed fromJson(string $value, bool $asObject = false) Decode the given JSON back into an array or object. Parameters string $value bool $asObject Return Value mixed mixed fromEncryptedString(string $value) Decrypt the given encrypted string. Parameters string $value Return Value mixed protected string castAttributeAsEncryptedString(string $key, mixed $value) Cast the given attribute to an encrypted string. Parameters string $key mixed $value Return Value string static void encryptUsing(Encrypter $encrypter) Set the encrypter instance that will be used to encrypt attributes. Parameters Encrypter $encrypter Return Value void mixed fromFloat(mixed $value) Decode the given float. Parameters mixed $value Return Value mixed protected string asDecimal(float $value, int $decimals) Return a decimal as string. Parameters float $value int $decimals Return Value string protected Carbon asDate(mixed $value) Return a timestamp as DateTime object with time set to 00:00:00. Parameters mixed $value Return Value Carbon protected Carbon asDateTime(mixed $value) Return a timestamp as DateTime object. Parameters mixed $value Return Value Carbon protected bool isStandardDateFormat(string $value) Determine if the given value is a standard date format. Parameters string $value Return Value bool string|null fromDateTime(mixed $value) Convert a DateTime to a storable string. Parameters mixed $value Return Value string|null protected int asTimestamp(mixed $value) Return a timestamp as unix timestamp. Parameters mixed $value Return Value int protected string serializeDate(DateTimeInterface $date) Prepare a date for array / JSON serialization. Parameters DateTimeInterface $date Return Value string array getDates() Get the attributes that should be converted to dates. Return Value array string getDateFormat() Get the format for database stored dates. Return Value string $this setDateFormat(string $format) Set the date format used by the model. Parameters string $format Return Value $this bool hasCast(string $key, array|string|null $types = null) Determine whether an attribute should be cast to a native type. Parameters string $key array|string|null $types Return Value bool array getCasts() Get the casts array. Return Value array protected bool isDateCastable(string $key) Determine whether a value is Date / DateTime castable for inbound manipulation. Parameters string $key Return Value bool protected bool isJsonCastable(string $key) Determine whether a value is JSON castable for inbound manipulation. Parameters string $key Return Value bool protected bool isEncryptedCastable(string $key) Determine whether a value is an encrypted castable for inbound manipulation. Parameters string $key Return Value bool protected bool isClassCastable(string $key) Determine if the given key is cast using a custom class. Parameters string $key Return Value bool protected bool isClassDeviable(string $key) Determine if the key is deviable using a custom class. Parameters string $key Return Value bool Exceptions InvalidCastException protected bool isClassSerializable(string $key) Determine if the key is serializable using a custom class. Parameters string $key Return Value bool Exceptions InvalidCastException protected mixed resolveCasterClass(string $key) Resolve the custom caster class for a given key. Parameters string $key Return Value mixed protected string parseCasterClass(string $class) Parse the given caster class, removing any arguments. Parameters string $class Return Value string protected void mergeAttributesFromClassCasts() Merge the cast class attributes back into the model. Return Value void protected array normalizeCastClassResponse(string $key, mixed $value) Normalize the response from a custom class caster. Parameters string $key mixed $value Return Value array array getAttributes() Get all of the current attributes on the model. Return Value array $this setRawAttributes(array $attributes, bool $sync = false) Set the array of model attributes. No checking is done. Parameters array $attributes bool $sync Return Value $this mixed|array getOriginal(string|null $key = null, mixed $default = null) Get the model's original attribute values. Parameters string|null $key mixed $default Return Value mixed|array protected mixed|array getOriginalWithoutRewindingModel(string|null $key = null, mixed $default = null) Get the model's original attribute values. Parameters string|null $key mixed $default Return Value mixed|array mixed|array getRawOriginal(string|null $key = null, mixed $default = null) Get the model's raw original attribute values. Parameters string|null $key mixed $default Return Value mixed|array array only(array|mixed $attributes) Get a subset of the model's attributes. Parameters array|mixed $attributes Return Value array $this syncOriginal() Sync the original attributes with the current. Return Value $this $this syncOriginalAttribute(string $attribute) Sync a single original attribute with its current value. Parameters string $attribute Return Value $this $this syncOriginalAttributes(array|string $attributes) Sync multiple original attribute with their current values. Parameters array|string $attributes Return Value $this $this syncChanges() Sync the changed attributes. Return Value $this bool isDirty(array|string|null $attributes = null) Determine if the model or any of the given attribute(s) have been modified. Parameters array|string|null $attributes Return Value bool bool isClean(array|string|null $attributes = null) Determine if the model and all the given attribute(s) have remained the same. Parameters array|string|null $attributes Return Value bool bool wasChanged(array|string|null $attributes = null) Determine if the model or any of the given attribute(s) have been modified. Parameters array|string|null $attributes Return Value bool protected bool hasChanges(array $changes, array|string|null $attributes = null) Determine if any of the given attributes were changed. Parameters array $changes array|string|null $attributes Return Value bool array getDirty() Get the attributes that have been changed since last sync. Return Value array array getChanges() Get the attributes that were changed. Return Value array bool originalIsEquivalent(string $key) Determine if the new and old values for a given key are equivalent. Parameters string $key Return Value bool protected mixed transformModelValue(string $key, mixed $value) Transform a raw model value using mutators, casts, etc. Parameters string $key mixed $value Return Value mixed $this append(array|string $attributes) Append attributes to query when building a query. Parameters array|string $attributes Return Value $this $this setAppends(array $appends) Set the accessors to append to model arrays. Parameters array $appends Return Value $this bool hasAppended(string $attribute) Return whether the accessor attribute has been appended. Parameters string $attribute Return Value bool array getMutatedAttributes() Get the mutated attributes for a given instance. Return Value array static void cacheMutatedAttributes(string $class) Extract and cache all the mutated attributes of a class. Parameters string $class Return Value void static protected array getMutatorMethods(mixed $class) Get all of the attribute mutator methods. Parameters mixed $class Return Value array static void observe(object|array|string $classes) Register observers with the model. Parameters object|array|string $classes Return Value void Exceptions RuntimeException protected void registerObserver(object|string $class) Register a single observer with the model. Parameters object|string $class Return Value void Exceptions RuntimeException array getObservableEvents() Get the observable event names. Return Value array $this setObservableEvents(array $observables) Set the observable event names. Parameters array $observables Return Value $this void addObservableEvents(array|mixed $observables) Add an observable event name. Parameters array|mixed $observables Return Value void void removeObservableEvents(array|mixed $observables) Remove an observable event name. Parameters array|mixed $observables Return Value void static protected void registerModelEvent(string $event, Closure|string $callback) Register a model event with the dispatcher. Parameters string $event Closure|string $callback Return Value void protected mixed fireModelEvent(string $event, bool $halt = true) Fire the given event for the model. Parameters string $event bool $halt Return Value mixed protected mixed|null fireCustomModelEvent(string $event, string $method) Fire a custom model event for the given event. Parameters string $event string $method Return Value mixed|null protected mixed filterModelEventResults(mixed $result) Filter the model event results. Parameters mixed $result Return Value mixed static void retrieved(Closure|string $callback) Register a retrieved model event with the dispatcher. Parameters Closure|string $callback Return Value void static void saving(Closure|string $callback) Register a saving model event with the dispatcher. Parameters Closure|string $callback Return Value void static void saved(Closure|string $callback) Register a saved model event with the dispatcher. Parameters Closure|string $callback Return Value void static void updating(Closure|string $callback) Register an updating model event with the dispatcher. Parameters Closure|string $callback Return Value void static void updated(Closure|string $callback) Register an updated model event with the dispatcher. Parameters Closure|string $callback Return Value void static void creating(Closure|string $callback) Register a creating model event with the dispatcher. Parameters Closure|string $callback Return Value void static void created(Closure|string $callback) Register a created model event with the dispatcher. Parameters Closure|string $callback Return Value void static void replicating(Closure|string $callback) Register a replicating model event with the dispatcher. Parameters Closure|string $callback Return Value void static void deleting(Closure|string $callback) Register a deleting model event with the dispatcher. Parameters Closure|string $callback Return Value void static void deleted(Closure|string $callback) Register a deleted model event with the dispatcher. Parameters Closure|string $callback Return Value void static void flushEventListeners() Remove all of the event listeners for the model. Return Value void static Dispatcher getEventDispatcher() Get the event dispatcher instance. Return Value Dispatcher static void setEventDispatcher(Dispatcher $dispatcher) Set the event dispatcher instance. Parameters Dispatcher $dispatcher Return Value void static void unsetEventDispatcher() Unset the event dispatcher for models. Return Value void static mixed withoutEvents(callable $callback) Execute a callback without firing any model events for any model type. Parameters callable $callback Return Value mixed static mixed addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null) Register a new global scope on the model. Parameters Scope|Closure|string $scope Closure $implementation Return Value mixed Exceptions InvalidArgumentException static bool hasGlobalScope(Scope|string $scope) Determine if a model has a global scope. Parameters Scope|string $scope Return Value bool static Scope|Closure|null getGlobalScope(Scope|string $scope) Get a global scope registered with the model. Parameters Scope|string $scope Return Value Scope|Closure|null array getGlobalScopes() Get the global scopes for this class instance. Return Value array static void resolveRelationUsing(string $name, Closure $callback) Define a dynamic relation resolver. Parameters string $name Closure $callback Return Value void HasOne hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null) Define a one-to-one relationship. Parameters string $related string|null $foreignKey string|null $localKey Return Value HasOne protected HasOne newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey) Instantiate a new HasOne relationship. Parameters Builder $query Model $parent string $foreignKey string $localKey Return Value HasOne HasOneThrough hasOneThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null) Define a has-one-through relationship. Parameters string $related string $through string|null $firstKey string|null $secondKey string|null $localKey string|null $secondLocalKey Return Value HasOneThrough protected HasOneThrough newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey) Instantiate a new HasOneThrough relationship. Parameters Builder $query Model $farParent Model $throughParent string $firstKey string $secondKey string $localKey string $secondLocalKey Return Value HasOneThrough MorphOne morphOne(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null) Define a polymorphic one-to-one relationship. Parameters string $related string $name string|null $type string|null $id string|null $localKey Return Value MorphOne protected MorphOne newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey) Instantiate a new MorphOne relationship. Parameters Builder $query Model $parent string $type string $id string $localKey Return Value MorphOne BelongsTo belongsTo(string $related, string|null $foreignKey = null, string|null $ownerKey = null, string|null $relation = null) Define an inverse one-to-one or many relationship. Parameters string $related string|null $foreignKey string|null $ownerKey string|null $relation Return Value BelongsTo protected BelongsTo newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation) Instantiate a new BelongsTo relationship. Parameters Builder $query Model $child string $foreignKey string $ownerKey string $relation Return Value BelongsTo MorphTo morphTo(string|null $name = null, string|null $type = null, string|null $id = null, string|null $ownerKey = null) Define a polymorphic, inverse one-to-one or many relationship. Parameters string|null $name string|null $type string|null $id string|null $ownerKey Return Value MorphTo protected MorphTo morphEagerTo(string $name, string $type, string $id, string $ownerKey) Define a polymorphic, inverse one-to-one or many relationship. Parameters string $name string $type string $id string $ownerKey Return Value MorphTo protected MorphTo morphInstanceTo(string $target, string $name, string $type, string $id, string $ownerKey) Define a polymorphic, inverse one-to-one or many relationship. Parameters string $target string $name string $type string $id string $ownerKey Return Value MorphTo protected MorphTo newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation) Instantiate a new MorphTo relationship. Parameters Builder $query Model $parent string $foreignKey string $ownerKey string $type string $relation Return Value MorphTo static string getActualClassNameForMorph(string $class) Retrieve the actual class name for a given morph class. Parameters string $class Return Value string protected string guessBelongsToRelation() Guess the "belongs to" relationship name. Return Value string HasMany hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null) Define a one-to-many relationship. Parameters string $related string|null $foreignKey string|null $localKey Return Value HasMany protected HasMany newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey) Instantiate a new HasMany relationship. Parameters Builder $query Model $parent string $foreignKey string $localKey Return Value HasMany HasManyThrough hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null) Define a has-many-through relationship. Parameters string $related string $through string|null $firstKey string|null $secondKey string|null $localKey string|null $secondLocalKey Return Value HasManyThrough protected HasManyThrough newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey) Instantiate a new HasManyThrough relationship. Parameters Builder $query Model $farParent Model $throughParent string $firstKey string $secondKey string $localKey string $secondLocalKey Return Value HasManyThrough MorphMany morphMany(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null) Define a polymorphic one-to-many relationship. Parameters string $related string $name string|null $type string|null $id string|null $localKey Return Value MorphMany protected MorphMany newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey) Instantiate a new MorphMany relationship. Parameters Builder $query Model $parent string $type string $id string $localKey Return Value MorphMany BelongsToMany belongsToMany(string $related, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, string|null $relation = null) Define a many-to-many relationship. Parameters string $related string|null $table string|null $foreignPivotKey string|null $relatedPivotKey string|null $parentKey string|null $relatedKey string|null $relation Return Value BelongsToMany protected BelongsToMany newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName = null) Instantiate a new BelongsToMany relationship. Parameters Builder $query Model $parent string $table string $foreignPivotKey string $relatedPivotKey string $parentKey string $relatedKey
{'path': 'public/docs/laravel~8/api/8.x/illuminate/foundation/auth/user.html', 'source': 'DevDocs.IO'}