Back
toggle()
Assigns to the property specified the opposite of the property's current boolean value.
Throws an error if the property cannot be converted to a boolean value.
Returns this object if save called internally is false
.
// Get an object, and toggle a boolean property user = model("user").findByKey(58); isSuccess = user.toggle("isActive"); // returns whether the object was saved properly // You can also use a dynamic helper for this isSuccess = user.toggleIsActive();
Copied!