Skip to content

Model Configuration

Model Configuration

  • accessibleProperties() — Use this method inside your model’s config() function to whitelist which properties can be set via mass assignment opera
  • afterCreate() — Registers one or more callback methods that are automatically executed after a new object is created (i.e., after callin
  • afterDelete() — Registers one or more callback methods that should be executed after an object is deleted from the database. This hook a
  • afterFind() — Registers one or more callback methods that should be executed after an existing object has been initialized, typically
  • afterInitialization() — Registers one or more callback methods that should be executed after an object has been initialized. Initialization happ
  • afterNew() — Registers one or more callback methods that should be executed after a new object has been initialized, typically via th
  • afterSave() — Registers one or more callback methods that should be executed after an object is saved to the database. This hook runs
  • afterUpdate() — Registers one or more callback methods that should be executed after an existing object has been updated in the database
  • afterValidation() — Registers one or more callback methods that should be executed after an object has been validated. This hook is useful f
  • afterValidationOnCreate() — Registers one or more callback methods that should be executed after a new object has been validated (i.e., when running
  • afterValidationOnUpdate() — Registers one or more callback methods that should be executed after an existing object has been validated (i.e., when r
  • automaticValidations() — Controls whether automatic validations should be enabled for a specific model. By default, Wheels can automatically infe
  • beforeCreate() — Registers method(s) that should be called before a new object is created. This allows you to modify or validate data, se
  • beforeDelete() — Registers method(s) that should be called before an object is deleted. This allows you to perform cleanup, enforce const
  • beforeSave() — Registers method(s) that should be called before an object is saved. This is useful for performing transformations, vali
  • beforeUpdate() — Registers method(s) that should be called before an existing object is updated. This is useful for enforcing rules, tran
  • beforeValidation() — Registers method(s) that should be called before an object is validated. This hook is helpful when you want to adjust, n
  • beforeValidationOnCreate() — Registers method(s) that should be called before a new object is validated. This hook is useful when you want to prepare
  • beforeValidationOnUpdate() — Registers method(s) that should be called before an existing object is validated. This hook is useful when you want to a
  • belongsTo() — Sets up a belongsTo association between this model and another model. Use this when the current model contains a foreign
  • dataSource() — dataSource() is a model configuration method used to override the default database connection for a specific model. This
  • hasMany() — Sets up a one-to-many association between the current model and another model. This allows you to easily fetch, join, an
  • hasOne() — Defines a one-to-one relationship between two models. It means each instance of this model is linked to exactly one reco
  • nestedProperties() — Allows nested objects, arrays, or structs associated with a model to be automatically set from incoming params or other
  • property() — Lets you customize how model properties map to database columns or SQL expressions. By default, Wheels automatically map
  • protectedProperties() — Used to protect one or more model properties from being set or modified through mass assignment operations. Mass assignm
  • setPrimaryKey() — The setPrimaryKey() function allows you to define which property (or properties) of a model represent the primary key in
  • setPrimaryKeys() — Alias for setPrimaryKey().
  • setTableNamePrefix() — Allows you to add a prefix to the table name used by a model when performing SQL queries. This is useful if your databas
  • table() — Used to tell Wheels which database table a model should connect to. Normally, Wheels automatically maps a model name to
  • validate() — Used to register one or more validation methods that will be executed on a model object before it is saved to the databa
  • validateOnCreate() — Registers one or more validation methods that will be executed only when a new object is being inserted into the databas
  • validateOnUpdate() — Registers one or more validation methods that will be executed only when an existing object is being updated in the data
  • validatesConfirmationOf() — Validates that the value of the specified property also has an identical confirmation value.
  • validatesExclusionOf() — Ensures that the value of a specified property is not included in a given list of disallowed values. This is commonly us
  • validatesFormatOf() — Validates that the value of the specified property is formatted correctly by matching it against a regular expression us
  • validatesInclusionOf() — Ensures that a property’s value exists in a predefined list of allowed values. It is commonly used for dropdowns, radio
  • validatesLengthOf() — Validates that the value of the specified property matches the length requirements supplied.
  • validatesNumericalityOf() — Ensures that a property’s value is numeric. You can also enforce additional constraints such as integer-only values, odd
  • validatesPresenceOf() — Ensures that the specified property (or properties) exists and is not blank. It is commonly used to enforce required fie
  • validatesUniquenessOf() — Validates that the value of the specified property is unique in the database table.