public loadDefaultValues ( boolean $skipIfSet = true ) | ||
$skipIfSet | boolean | whether existing value should be preserved. This will only set defaults for attributes that are `null`. |
public function loadDefaultValues($skipIfSet = true)
{
foreach (static::getTableSchema()->columns as $column) {
if ($column->defaultValue !== null && (!$skipIfSet || $this->{$column->name} === null)) {
$this->{$column->name} = $column->defaultValue;
}
}
return $this;
}