protected function insertInternal($attributes = null, $connection = null)
    {
        if (!$this->beforeSave(true)) {
            return reject(false);
        }
        $values = $this->getDirtyAttributes($attributes);
        return static::getDb()->getSchema()->insert(static::tableName(), $values, $connection)->then(
            function($primaryKeys) use ($values) {
                if ($primaryKeys === false) {
                    return reject(false);
                }
                foreach ($primaryKeys as $name => $value) {
                    $id = static::getTableSchema()->columns[$name]->phpTypecast($value);
                    $this->setAttribute($name, $id);
                    $values[$name] = $id;
                }

                $changedAttributes = array_fill_keys(array_keys($values), null);
                $this->setOldAttributes($values);
                $this->afterSave(true, $changedAttributes);
                return true;
            }
        );
    }