public function assign($data, $whiteList = null)
    {
        if ($whiteList === null) {
            $whiteList = $this->getSafeFields();
        }

        if ($whiteList === null) {
            throw new PreconditionException(['`:model` model do not define accessible fields.', 'model' => static::class]);
        }

        foreach ($whiteList ?: $this->getFields() as $field) {
            if (isset($data[$field])) {
                $value = $data[$field];
                $this->{$field} = is_string($value) ? trim($value) : $value;
            }
        }

        return $this;
    }