fill method

void fill(
  1. Map<String, dynamic> attributes, {
  2. bool strict = false,
})

Fill the model with an array of attributes.

Only fills attributes that are in the fillable list, unless fillable is empty and guarded doesn't include '*'.

When strict is true, any attribute that fails the fillable guard throws MassAssignmentException instead of being silently dropped. Use strict mode when pairing with validated request data to catch schema drift early.

Implementation

void fill(Map<String, dynamic> attributes, {bool strict = false}) {
  for (final entry in attributes.entries) {
    if (_isFillable(entry.key)) {
      setAttribute(entry.key, entry.value);
    } else if (strict) {
      throw MassAssignmentException(entry.key, runtimeType);
    }
  }
}