Skip to content

Model Object

Model Object

  • addError() — Adds an error on a specific property.
  • addErrorToBase() — Adds an error on a specific property.
  • allAssociationErrors() — Gets all associated errors recursively
  • allChanges() — Returns a struct detailing all changes that have been made on the object but not yet saved to the database.
  • allErrors() — Returns an array of all the errors on the object.
  • changedFrom() — Returns the previous value of a property that has changed.
  • changedProperties() — Returns a list of the object properties that have been changed but not yet saved to the database.
  • clearChangeInformation() — Clears all internal knowledge of the current state of the object.
  • clearErrors() — Clears out all errors set on the object or only the ones set for a specific property or name.
  • compareTo() — Pass in another model object to see if the two objects are the same.
  • delete() — Deletes the object, which means the row is deleted from the database (unless prevented by a beforeDelete ca
  • errorCount() — Returns the number of errors this object has associated with it.
  • errorsOn() — Returns an array of all errors associated with the supplied property (and error name if passed in).
  • errorsOnBase() — Returns an array of all errors associated with the object as a whole (not related to any specific property).
  • hasChanged() — Returns true if the specified property (or any if none was passed in) has been changed but not yet saved to
  • hasErrors() — Returns true if the object has any errors.
  • hasProperty() — Returns true if the specified property name exists on the model.
  • isNew() — Returns true if this object hasn’t been saved yet (in other words, no matching record exists in the databas
  • isPersisted() — Returns true if this object has been persisted to the database or was loaded from the database via a finder
  • key() — Returns the value of the primary key for the object.
  • properties() — Returns a structure of all the properties with their names as keys and the values of the property as values.
  • propertyIsBlank() — Returns true if the specified property doesn’t exist on the model or is an empty string.
  • propertyIsPresent() — Returns true if the specified property exists on the model and is not a blank string.
  • reload() — Reloads the property values of this object from the database.
  • setProperties() — Allows you to set all the properties of an object at once by passing in a structure with keys matching the property name
  • toggle() — Assigns to the property specified the opposite of the property’s current boolean value.
  • update() — Updates the object with the supplied properties and saves it to the database.
  • updateProperty() — Updates a single property and saves the record without going through the normal validation procedure.
  • valid() — Runs the validation on the object and returns true if it passes it.