Skip to content

Model Configuration

enum()

enum() — returns void

Available in: model Category: Enum Functions

Maps a property to a set of named values (like Rails enums). Generates boolean checker methods (is()), scopes for each value, and validates that the property value is one of the allowed values.

NameTypeRequiredDefaultDescription
propertystringyesThe name of the model property to map as an enum.
valuesanyyesEither a comma-delimited list of string values (e.g. "draft,published,archived") or a struct mapping names to stored values (e.g. {low: 0, medium: 1, high: 2}).