Skip to content

Model Configuration

accessibleProperties()

accessibleProperties() — returns void

Available in: model Category: Miscellaneous Functions

Use this method to specify which properties can be set through mass assignment.

NameTypeRequiredDefaultDescription
propertiesstringno—Property name (or list of property names) that are allowed to be altered through mass assignment.
// Mass assignment is open by default: with neither accessibleProperties() nor
// protectedProperties(), every property can be set via new() / create() / update().
// set(massAssignmentStrict=true) fail-closes that case (opt-in; not the default).

// 1. Allow only `isActive` to be set through mass assignment (e.g. `updateAll()`, `new()`, `update()`).
config() {
	accessibleProperties("isActive");
}

// 2. Allow a comma-delimited list of properties to be set through mass assignment.
//    Any property not in this list is silently ignored when set via mass assignment.
config() {
	accessibleProperties("firstName,lastName,email");
}