DatabaseNotification
class DatabaseNotification extends Model (View source)
Constants
CREATED_AT | The name of the "created at" column. |
UPDATED_AT | The name of the "updated at" column. |
Properties
protected string | $connection | The connection name for the model. | from Model |
protected string | $table | The table associated with the model. | |
protected string | $primaryKey | The primary key for the model. | from Model |
protected string | $keyType | The "type" of the auto-incrementing ID. | from Model |
protected int | $perPage | The number of models to return for pagination. | from Model |
bool | $incrementing | Indicates if the IDs are auto-incrementing. | |
bool | $timestamps | Indicates if the model should be timestamped. | from Model |
protected array | $attributes | The model's attributes. | from Model |
protected array | $original | The model attribute's original state. | from Model |
protected array | $relations | The loaded relationships for the model. | from Model |
$hidden | The attributes that should be hidden for arrays. | from Model | |
protected array | $visible | The attributes that should be visible in arrays. | from Model |
protected array | $appends | The accessors to append to the model's array form. | from Model |
protected array | $fillable | The attributes that are mass assignable. | from Model |
protected array | $guarded | The guarded attributes on the model. | |
protected array | $dates | The attributes that should be mutated to dates. | from Model |
protected string | $dateFormat | The storage format of the model's date columns. | from Model |
protected array | $casts | The attributes that should be cast to native types. | |
protected array | $touches | The relationships that should be touched on save. | from Model |
protected array | $observables | User exposed observable events. | from Model |
protected array | $with | The relations to eager load on every query. | 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 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 | $globalScopes | The array of global scopes on the model. | from Model |
static protected bool | $unguarded | Indicates if all mass assignment is enabled. | from Model |
static protected array | $mutatorCache | The cache of the mutated attributes for each class. | from Model |
static array | $manyMethods | The many to many relationship methods. | from Model |
Methods
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 | boot() The "booting" method of the model. | from Model |
static void | bootTraits() Boot all of the bootable traits on the model. | from Model |
static void | clearBootedModels() Clear the list of booted models so they will be re-booted. | from Model |
static mixed | addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null) Register a new global scope on the model. | from Model |
static bool | hasGlobalScope(Scope|string $scope) Determine if a model has a global scope. | from Model |
static Scope|Closure|null | getGlobalScope(Scope|string $scope) Get a global scope registered with the model. | from Model |
array | getGlobalScopes() Get the global scopes for this class instance. | from Model |
static void | observe(object|string $class, int $priority) Register an observer with the Model. | 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 |
array | fillableFromArray(array $attributes) Get the fillable attributes of a given array. | 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 Collection | hydrate(array $items, string|null $connection = null) Create a collection of models from plain arrays. | from Model |
static Collection | hydrateRaw(string $query, array $bindings = [], string|null $connection = null) Create a collection of models from a raw query. | from Model |
static Model | create(array $attributes = []) Save a new model and return the instance. | from Model |
static Model | forceCreate(array $attributes) Save a new model and return the instance. Allow mass-assignment. | from Model |
static Builder | query() Begin querying the model. | 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 |
Model|null | fresh(array|string $with = []) Reload a fresh model instance from the database. | from Model |
$this | load(array|string $relations) Eager load relations on the model. | from Model |
static Builder|Model | with(array|string $relations) Begin querying a model with eager loading. | from Model |
$this | append(array|string $attributes) Append attributes to query when building a query. | from Model |
HasOne | hasOne(string $related, string $foreignKey = null, string $localKey = null) Define a one-to-one relationship. | from Model |
MorphOne | morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null) Define a polymorphic one-to-one relationship. | from Model |
BelongsTo | belongsTo(string $related, string $foreignKey = null, string $otherKey = null, string $relation = null) Define an inverse one-to-one or many relationship. | from Model |
MorphTo | morphTo(string $name = null, string $type = null, string $id = null) Define a polymorphic, inverse one-to-one or many relationship. | from Model |
string | getActualClassNameForMorph(string $class) Retrieve the fully qualified class name from a slug. | from Model |
HasMany | hasMany(string $related, string $foreignKey = null, string $localKey = null) Define a one-to-many relationship. | from Model |
HasManyThrough | hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null) Define a has-many-through relationship. | from Model |
MorphMany | morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null) Define a polymorphic one-to-many relationship. | from Model |
BelongsToMany | belongsToMany(string $related, string $table = null, string $foreignKey = null, string $otherKey = null, string $relation = null) Define a many-to-many relationship. | from Model |
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. | from Model |
MorphToMany | morphedByMany(string $related, string $name, string $table = null, string $foreignKey = null, string $otherKey = null) Define a polymorphic, inverse many-to-many relationship. | from Model |
string | getBelongsToManyCaller() Get the relationship name of the belongs to many. | from Model |
string | joiningTable(string $related) Get the joining table name for a many-to-many relation. | from Model |
static int | destroy(array|int $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 void | saving(Closure|string $callback, int $priority) Register a saving model event with the dispatcher. | from Model |
static void | saved(Closure|string $callback, int $priority) Register a saved model event with the dispatcher. | from Model |
static void | updating(Closure|string $callback, int $priority) Register an updating model event with the dispatcher. | from Model |
static void | updated(Closure|string $callback, int $priority) Register an updated model event with the dispatcher. | from Model |
static void | creating(Closure|string $callback, int $priority) Register a creating model event with the dispatcher. | from Model |
static void | created(Closure|string $callback, int $priority) Register a created model event with the dispatcher. | from Model |
static void | deleting(Closure|string $callback, int $priority) Register a deleting model event with the dispatcher. | from Model |
static void | deleted(Closure|string $callback, int $priority) Register a deleted model event with the dispatcher. | from Model |
static void | flushEventListeners() Remove all of the event listeners for the model. | from Model |
static void | registerModelEvent(string $event, Closure|string $callback, int $priority) Register a model event with the dispatcher. | from Model |
array | getObservableEvents() Get the observable event names. | from Model |
$this | setObservableEvents(array $observables) Set the observable event names. | from Model |
void | addObservableEvents(array|mixed $observables) Add an observable event name. | from Model |
void | removeObservableEvents(array|mixed $observables) Remove an observable event name. | from Model |
int | increment(string $column, int $amount = 1, array $extra = []) Increment a column's value by a given amount. | from Model |
int | decrement(string $column, int $amount = 1, array $extra = []) Decrement a column's value by a given amount. | from Model |
int | incrementOrDecrement(string $column, int $amount, array $extra, string $method) Run the increment or decrement method on the model. | from Model |
void | incrementOrDecrementAttributeValue(string $column, int $amount, string $method) Increment the underlying attribute value and sync with original. | 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 | 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) Finish processing on a successful save operation. | from Model |
bool | performUpdate(Builder $query) Perform a model update operation. | 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 |
void | touchOwners() Touch the owning relations of the model. | from Model |
bool | touches(string $relation) Determine if the model touches a given relation. | from Model |
mixed | fireModelEvent(string $event, bool $halt = true) Fire the given event for the model. | 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 | touch() Update the model's update timestamp. | from Model |
void | updateTimestamps() Update the creation and update timestamps. | from Model |
$this | setCreatedAt(mixed $value) Set the value of the "created at" attribute. | from Model |
$this | setUpdatedAt(mixed $value) Set the value of the "updated at" attribute. | from Model |
string | getCreatedAtColumn() Get the name of the "created at" column. | from Model |
string | getUpdatedAtColumn() Get the name of the "updated at" column. | from Model |
Carbon | freshTimestamp() Get a fresh timestamp for the model. | from Model |
string | freshTimestampString() Get a fresh timestamp for the model. | from Model |
Builder | newQuery() Get a new query builder for the model's table. | from Model |
Builder | newQueryWithoutScope(Scope|string $scope) Get a new query instance without a given scope. | from Model |
Builder|Model | newQueryWithoutScopes() Get a new query builder that doesn't have any global scopes. | 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 database notification collection instance. | |
Pivot | newPivot(Model $parent, array $attributes, string $table, bool $exists) Create a new pivot model instance. | 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 |
mixed | getKey() Get the value of the model's primary key. | from Model |
mixed | getQueueableId() Get the queueable identity for the entity. | 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 |
mixed | getRouteKey() Get the value of the model's route key. | from Model |
string | getRouteKeyName() Get the route key for the model. | from Model |
bool | usesTimestamps() Determine if the model uses timestamps. | from Model |
array | getMorphs(string $name, string $type, string $id) Get the polymorphic relationship columns. | from Model |
string | getMorphClass() Get the class name for polymorphic relations. | 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 |
string | getForeignKey() Get the default foreign key name for the model. | from Model |
array | getHidden() Get the hidden attributes for the model. | from Model |
$this | setHidden(array $hidden) Set the hidden attributes for the model. | from Model |
void | addHidden(array|string|null $attributes = null) Add hidden attributes for the model. | from Model |
$this | makeVisible(array|string $attributes) Make the given, typically hidden, attributes visible. | from Model |
$this | makeHidden(array|string $attributes) Make the given, typically visible, attributes hidden. | from Model |
array | getVisible() Get the visible attributes for the model. | from Model |
$this | setVisible(array $visible) Set the visible attributes for the model. | from Model |
void | addVisible(array|string|null $attributes = null) Add visible attributes for the model. | from Model |
$this | setAppends(array $appends) Set the accessors to append to model arrays. | from Model |
array | getFillable() Get the fillable attributes for the model. | from Model |
$this | fillable(array $fillable) Set the fillable attributes for the model. | from Model |
array | getGuarded() Get the guarded attributes for the model. | from Model |
$this | guard(array $guarded) Set the guarded attributes for the model. | from Model |
static void | unguard(bool $state = true) Disable all mass assignable restrictions. | from Model |
static void | reguard() Enable the mass assignment restrictions. | from Model |
static bool | isUnguarded() Determine if current state is "unguarded". | from Model |
static mixed | unguarded(callable $callback) Run the given callable while being unguarded. | from Model |
bool | isFillable(string $key) Determine if the given attribute may be mass assigned. | from Model |
bool | isGuarded(string $key) Determine if the given key is guarded. | from Model |
bool | totallyGuarded() Determine if the model is totally guarded. | from Model |
string | removeTableFromKey(string $key) Remove the table name from a given key. | from Model |
array | getTouchedRelations() Get the relationships that are touched on save. | from Model |
$this | setTouchedRelations(array $touches) Set the relationships that are touched on save. | 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 |
string | toJson(int $options) Convert the model instance to JSON. | from Model |
array | jsonSerialize() Convert the object into something JSON serializable. | from Model |
array | toArray() Convert the model instance to an array. | from Model |
array | attributesToArray() Convert the model's attributes to an array. | from Model |
array | getArrayableAttributes() Get an attribute array of all arrayable attributes. | from Model |
array | getArrayableAppends() Get all of the appendable values that are arrayable. | from Model |
array | relationsToArray() Get the model's relationships in array form. | from Model |
array | getArrayableRelations() Get an attribute array of all arrayable relations. | from Model |
array | getArrayableItems(array $values) Get an attribute array of all arrayable values. | from Model |
mixed | getAttribute(string $key) Get an attribute from the model. | from Model |
mixed | getAttributeValue(string $key) Get a plain attribute (not a relationship). | from Model |
mixed | getRelationValue(string $key) Get a relationship. | from Model |
mixed | getAttributeFromArray(string $key) Get an attribute from the $attributes array. | from Model |
mixed | getRelationshipFromMethod(string $method) Get a relationship value from a method. | from Model |
bool | hasGetMutator(string $key) Determine if a get mutator exists for an attribute. | from Model |
mixed | mutateAttribute(string $key, mixed $value) Get the value of an attribute using its mutator. | from Model |
mixed | mutateAttributeForArray(string $key, mixed $value) Get the value of an attribute using its mutator for array conversion. | from Model |
bool | hasCast(string $key, array|string|null $types = null) Determine whether an attribute should be cast to a native type. | from Model |
array | getCasts() Get the casts array. | from Model |
bool | isDateCastable(string $key) Determine whether a value is Date / DateTime castable for inbound manipulation. | from Model |
bool | isJsonCastable(string $key) Determine whether a value is JSON castable for inbound manipulation. | from Model |
string | getCastType(string $key) Get the type of cast for a model attribute. | from Model |
mixed | castAttribute(string $key, mixed $value) Cast an attribute to a native PHP type. | from Model |
$this | setAttribute(string $key, mixed $value) Set a given attribute on the model. | from Model |
$this | fillJsonAttribute(string $key, mixed $value) Set a given JSON attribute on the model. | from Model |
bool | hasSetMutator(string $key) Determine if a set mutator exists for an attribute. | from Model |
array | getDates() Get the attributes that should be converted to dates. | from Model |
string | fromDateTime(DateTime|int $value) Convert a DateTime to a storable string. | from Model |
Carbon | asDateTime(mixed $value) Return a timestamp as DateTime object. | from Model |
int | asTimeStamp(mixed $value) Return a timestamp as unix timestamp. | from Model |
string | serializeDate(DateTimeInterface $date) Prepare a date for array / JSON serialization. | from Model |
string | getDateFormat() Get the format for database stored dates. | from Model |
$this | setDateFormat(string $format) Set the date format used by the model. | from Model |
string | asJson(mixed $value) Encode the given value as JSON. | from Model |
mixed | fromJson(string $value, bool $asObject = false) Decode the given JSON back into an array or object. | from Model |
Model | replicate(array $except = null) Clone the model into a new, non-existing instance. | from Model |
bool | is(Model $model) Determine if two models have the same ID and belong to the same table. | from Model |
array | getAttributes() Get all of the current attributes on the model. | from Model |
$this | setRawAttributes(array $attributes, bool $sync = false) Set the array of model attributes. No checking is done. | from Model |
mixed|array | getOriginal(string|null $key = null, mixed $default = null) Get the model's original attribute values. | from Model |
$this | syncOriginal() Sync the original attributes with the current. | from Model |
$this | syncOriginalAttribute(string $attribute) Sync a single original attribute with its current value. | from Model |
bool | isDirty(array|string|null $attributes = null) Determine if the model or given attribute(s) have been modified. | from Model |
bool | isClean(array|string|null $attributes = null) Determine if the model or given attribute(s) have remained the same. | from Model |
array | getDirty() Get the attributes that have been changed since last sync. | from Model |
bool | originalIsNumericallyEquivalent(string $key) Determine if the new and old values for a given key are numerically equivalent. | from Model |
array | getRelations() Get all the loaded relations for the instance. | from Model |
mixed | getRelation(string $relation) Get a specified relationship. | from Model |
bool | relationLoaded(string $key) Determine if the given relation is loaded. | from Model |
$this | setRelation(string $relation, mixed $value) Set the specific relationship in the model. | from Model |
$this | setRelations(array $relations) Set the entire relations array on the model. | from Model |
Connection | getConnection() Get the database connection for the model. | from Model |
string | getConnectionName() Get the current connection name for the model. | from Model |
$this | setConnection(string $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 |
static Dispatcher | getEventDispatcher() Get the event dispatcher instance. | from Model |
static void | setEventDispatcher(Dispatcher $dispatcher) Set the event dispatcher instance. | from Model |
static void | unsetEventDispatcher() Unset the event dispatcher for models. | from Model |
array | getMutatedAttributes() Get the mutated attributes for a given instance. | from Model |
static void | cacheMutatedAttributes(string $class) Extract and cache all the mutated attributes of a class. | 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 method. | from Model |
string | __toString() Convert the model to its string representation. | from Model |
void | __wakeup() When a model is being unserialized, check if it needs to be booted. | from Model |
notifiable() Get the notifiable entity that the notification belongs to. | ||
void | markAsRead() Mark the notification as read. | |
bool | read() Determine if a notification has been read. | |
bool | unread() Determine if a notification has not been read. |
Details
void __construct(array $attributes = [])
Create a new Eloquent model instance.
protected void bootIfNotBooted()
Check if the model needs to be booted and if so, do it.
static protected void boot()
The "booting" method of the model.
static protected void bootTraits()
Boot all of the bootable traits on the model.
static void clearBootedModels()
Clear the list of booted models so they will be re-booted.
static mixed addGlobalScope(Scope|Closure|string $scope, Closure $implementation = null)
Register a new global scope on the model.
static bool hasGlobalScope(Scope|string $scope)
Determine if a model has a global scope.
static Scope|Closure|null getGlobalScope(Scope|string $scope)
Get a global scope registered with the model.
array getGlobalScopes()
Get the global scopes for this class instance.
static void observe(object|string $class, int $priority)
Register an observer with the Model.
$this fill(array $attributes)
Fill the model with an array of attributes.
$this forceFill(array $attributes)
Fill the model with an array of attributes. Force mass assignment.
protected array fillableFromArray(array $attributes)
Get the fillable attributes of a given array.
Model newInstance(array $attributes = [], bool $exists = false)
Create a new instance of the given model.
Model newFromBuilder(array $attributes = [], 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 = [], string|null $connection = null)
Create a collection of models from a raw query.
static Model create(array $attributes = [])
Save a new model and return the instance.
static Model forceCreate(array $attributes)
Save a new model and return the instance. Allow mass-assignment.
static Builder query()
Begin querying the model.
static Builder on(string|null $connection = null)
Begin querying the model on a given connection.
static Builder onWriteConnection()
Begin querying the model on the write connection.
static Collection|Model[] all(array|mixed $columns = ['*'])
Get all of the models from the database.
Model|null fresh(array|string $with = [])
Reload a fresh model instance from the database.
$this load(array|string $relations)
Eager load relations on the model.
$this append(array|string $attributes)
Append attributes to query when building a query.
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.
protected string getBelongsToManyCaller()
Get the relationship name of the belongs to many.
string joiningTable(string $related)
Get the joining table name for a many-to-many relation.
static int destroy(array|int $ids)
Destroy the models for the given IDs.
bool|null delete()
Delete the model from the database.
bool|null forceDelete()
Force a hard delete on a soft deleted model.
This method protects developers from running forceDelete when trait is missing.
protected void performDeleteOnModel()
Perform the actual delete query on this model instance.
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.
static void flushEventListeners()
Remove all of the event listeners for the model.
static protected void registerModelEvent(string $event, Closure|string $callback, int $priority)
Register a model event with the dispatcher.
array getObservableEvents()
Get the observable event names.
$this setObservableEvents(array $observables)
Set the observable event names.
void addObservableEvents(array|mixed $observables)
Add an observable event name.
void removeObservableEvents(array|mixed $observables)
Remove an observable event name.
protected int increment(string $column, int $amount = 1, array $extra = [])
Increment a column's value by a given amount.
protected int decrement(string $column, int $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
protected int incrementOrDecrement(string $column, int $amount, array $extra, string $method)
Run the increment or decrement method on the model.
protected void incrementOrDecrementAttributeValue(string $column, int $amount, string $method)
Increment the underlying attribute value and sync with original.
bool update(array $attributes = [], array $options = [])
Update the model in the database.
bool push()
Save the model and all of its relationships.
bool save(array $options = [])
Save the model to the database.
bool saveOrFail(array $options = [])
Save the model to the database using transaction.
protected void finishSave(array $options)
Finish processing on a successful save operation.
protected bool performUpdate(Builder $query)
Perform a model update operation.
protected bool performInsert(Builder $query)
Perform a model insert operation.
protected void insertAndSetId(Builder $query, array $attributes)
Insert the given attributes and set the ID on the model.
void touchOwners()
Touch the owning relations of the model.
bool touches(string $relation)
Determine if the model touches a given relation.
protected mixed fireModelEvent(string $event, bool $halt = true)
Fire the given event for the model.
protected mixed getKeyForSaveQuery()
Get the primary key value for a save query.
bool touch()
Update the model's update timestamp.
protected void updateTimestamps()
Update the creation and update timestamps.
$this setCreatedAt(mixed $value)
Set the value of the "created at" attribute.
$this setUpdatedAt(mixed $value)
Set the value of the "updated at" attribute.
string getCreatedAtColumn()
Get the name of the "created at" column.
string getUpdatedAtColumn()
Get the name of the "updated at" column.
Carbon freshTimestamp()
Get a fresh timestamp for the model.
string freshTimestampString()
Get a fresh timestamp for the model.
Builder newQuery()
Get a new query builder for the model's table.
protected Builder newBaseQueryBuilder()
Get a new query builder instance for the connection.
Collection newCollection(array $models = [])
Create a new database notification collection instance.
Pivot newPivot(Model $parent, array $attributes, string $table, bool $exists)
Create a new pivot model instance.
string getTable()
Get the table associated with the model.
$this setTable(string $table)
Set the table associated with the model.
mixed getKey()
Get the value of the model's primary key.
mixed getQueueableId()
Get the queueable identity for the entity.
string getKeyName()
Get the primary key for the model.
$this setKeyName(string $key)
Set the primary key for the model.
string getQualifiedKeyName()
Get the table qualified key name.
string getKeyType()
Get the auto incrementing key type.
mixed getRouteKey()
Get the value of the model's route key.
string getRouteKeyName()
Get the route key for the model.
bool usesTimestamps()
Determine if the model uses timestamps.
protected array getMorphs(string $name, string $type, string $id)
Get the polymorphic relationship columns.
string getMorphClass()
Get the class name for polymorphic relations.
int getPerPage()
Get the number of models to return per page.
$this setPerPage(int $perPage)
Set the number of models to return per page.
string getForeignKey()
Get the default foreign key name for the model.
array getHidden()
Get the hidden attributes for the model.
$this setHidden(array $hidden)
Set the hidden attributes for the model.
void addHidden(array|string|null $attributes = null)
Add hidden attributes for the model.
$this makeVisible(array|string $attributes)
Make the given, typically hidden, attributes visible.
$this makeHidden(array|string $attributes)
Make the given, typically visible, attributes hidden.
array getVisible()
Get the visible attributes for the model.
$this setVisible(array $visible)
Set the visible attributes for the model.
void addVisible(array|string|null $attributes = null)
Add visible attributes for the model.
$this setAppends(array $appends)
Set the accessors to append to model arrays.
array getFillable()
Get the fillable attributes for the model.
$this fillable(array $fillable)
Set the fillable attributes for the model.
array getGuarded()
Get the guarded attributes for the model.
$this guard(array $guarded)
Set the guarded attributes for the model.
static void unguard(bool $state = true)
Disable all mass assignable restrictions.
static void reguard()
Enable the mass assignment restrictions.
static bool isUnguarded()
Determine if current state is "unguarded".
static mixed unguarded(callable $callback)
Run the given callable while being unguarded.
bool isFillable(string $key)
Determine if the given attribute may be mass assigned.
bool isGuarded(string $key)
Determine if the given key is guarded.
bool totallyGuarded()
Determine if the model is totally guarded.
protected string removeTableFromKey(string $key)
Remove the table name from a given key.
array getTouchedRelations()
Get the relationships that are touched on save.
$this setTouchedRelations(array $touches)
Set the relationships that are touched on save.
bool getIncrementing()
Get the value indicating whether the IDs are incrementing.
$this setIncrementing(bool $value)
Set whether IDs are incrementing.
string toJson(int $options)
Convert the model instance to JSON.
array jsonSerialize()
Convert the object into something JSON serializable.
array toArray()
Convert the model instance to an array.
array attributesToArray()
Convert the model's attributes to an array.
protected array getArrayableAttributes()
Get an attribute array of all arrayable attributes.
protected array getArrayableAppends()
Get all of the appendable values that are arrayable.
array relationsToArray()
Get the model's relationships in array form.
protected array getArrayableRelations()
Get an attribute array of all arrayable relations.
protected array getArrayableItems(array $values)
Get an attribute array of all arrayable values.
mixed getAttribute(string $key)
Get an attribute from the model.
mixed getAttributeValue(string $key)
Get a plain attribute (not a relationship).
mixed getRelationValue(string $key)
Get a relationship.
protected mixed getAttributeFromArray(string $key)
Get an attribute from the $attributes array.
protected mixed getRelationshipFromMethod(string $method)
Get a relationship value from a method.
bool hasGetMutator(string $key)
Determine if a get mutator exists for an attribute.
protected mixed mutateAttribute(string $key, mixed $value)
Get the value of an attribute using its mutator.
protected mixed mutateAttributeForArray(string $key, mixed $value)
Get the value of an attribute using its mutator for array conversion.
bool hasCast(string $key, array|string|null $types = null)
Determine whether an attribute should be cast to a native type.
array getCasts()
Get the casts array.
protected bool isDateCastable(string $key)
Determine whether a value is Date / DateTime castable for inbound manipulation.
protected bool isJsonCastable(string $key)
Determine whether a value is JSON castable for inbound manipulation.
protected string getCastType(string $key)
Get the type of cast for a model attribute.
protected mixed castAttribute(string $key, mixed $value)
Cast an attribute to a native PHP type.
$this setAttribute(string $key, mixed $value)
Set a given attribute on the model.
$this fillJsonAttribute(string $key, mixed $value)
Set a given JSON attribute on the model.
bool hasSetMutator(string $key)
Determine if a set mutator exists for an attribute.
array getDates()
Get the attributes that should be converted to dates.
string fromDateTime(DateTime|int $value)
Convert a DateTime to a storable string.
protected Carbon asDateTime(mixed $value)
Return a timestamp as DateTime object.
protected int asTimeStamp(mixed $value)
Return a timestamp as unix timestamp.
protected string serializeDate(DateTimeInterface $date)
Prepare a date for array / JSON serialization.
protected string getDateFormat()
Get the format for database stored dates.
$this setDateFormat(string $format)
Set the date format used by the model.
protected string asJson(mixed $value)
Encode the given value as JSON.
mixed fromJson(string $value, bool $asObject = false)
Decode the given JSON back into an array or object.
Model replicate(array $except = null)
Clone the model into a new, non-existing instance.
bool is(Model $model)
Determine if two models have the same ID and belong to the same table.
array getAttributes()
Get all of the current attributes on the model.
$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 syncOriginal()
Sync the original attributes with the current.
$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.
bool isClean(array|string|null $attributes = null)
Determine if the model or given attribute(s) have remained the same.
array getDirty()
Get the attributes that have been changed since last sync.
protected bool originalIsNumericallyEquivalent(string $key)
Determine if the new and old values for a given key are numerically equivalent.
array getRelations()
Get all the loaded relations for the instance.
mixed getRelation(string $relation)
Get a specified relationship.
bool relationLoaded(string $key)
Determine if the given relation is loaded.
$this setRelation(string $relation, mixed $value)
Set the specific relationship in the model.
$this setRelations(array $relations)
Set the entire relations array on the model.
Connection getConnection()
Get the database connection for the model.
string getConnectionName()
Get the current connection name for the model.
$this setConnection(string $name)
Set the connection associated with the model.
static Connection resolveConnection(string|null $connection = null)
Resolve a connection instance.
static ConnectionResolverInterface getConnectionResolver()
Get the connection resolver instance.
static void setConnectionResolver(ConnectionResolverInterface $resolver)
Set the connection resolver instance.
static void unsetConnectionResolver()
Unset the connection resolver for models.
static Dispatcher getEventDispatcher()
Get the event dispatcher instance.
static void setEventDispatcher(Dispatcher $dispatcher)
Set the event dispatcher instance.
static void unsetEventDispatcher()
Unset the event dispatcher for models.
array getMutatedAttributes()
Get the mutated attributes for a given instance.
static void cacheMutatedAttributes(string $class)
Extract and cache all the mutated attributes of a class.
mixed __get(string $key)
Dynamically retrieve attributes on the model.
void __set(string $key, mixed $value)
Dynamically set attributes on the model.
bool offsetExists(mixed $offset)
Determine if the given attribute exists.
mixed offsetGet(mixed $offset)
Get the value for a given offset.
void offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
void offsetUnset(mixed $offset)
Unset the value for a given offset.
bool __isset(string $key)
Determine if an attribute or relation exists on the model.
void __unset(string $key)
Unset an attribute on the model.
mixed __call(string $method, array $parameters)
Handle dynamic method calls into the model.
static mixed __callStatic(string $method, array $parameters)
Handle dynamic static method calls into the method.
string __toString()
Convert the model to its string representation.
void __wakeup()
When a model is being unserialized, check if it needs to be booted.
notifiable()
Get the notifiable entity that the notification belongs to.
void markAsRead()
Mark the notification as read.
bool read()
Determine if a notification has been read.
bool unread()
Determine if a notification has not been read.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Notifications/DatabaseNotification.html