Create an array of records to insert into the pivot table.

@param  array  $ids
@param  array  $attributes
@return array
425018
protected function createAttachRecords($ids, array $attributes)
	{
		$records = array();

		$timed = ($this->hasPivotColumn($this->createdAt()) ||
			      $this->hasPivotColumn($this->updatedAt()));

		// To create the attachment records, we will simply spin through the IDs given
		// and create a new record to insert for each ID. Each ID may actually be a
		// key in the array, with extra attributes to be placed in other columns.
		foreach ($ids as $key => $value)
		{
			$records[] = $this->attacher($key, $value, $attributes, $timed);
		}

		return $records;
	}
43376
public function toInsertSQL($attributes = array())
    {
        $sql = [];
        $this->params = [];
        
        $sql[] = sprintf('INSERT INTO %s', $this->table->getTableName());
        $keys = [];
        $values = [];
        foreach ($attributes as $key => $value) {
            $keys[] = $key;
            $values[] = '?';
            $this->addParam($value);
        }
        $sql[] = '(' . join(', ', $keys) . ')';
        $sql[] = 'VALUES (' . join(', ', $values) . ')';
        return join(' ', $sql);
    }
744800
public function createInput(array $attributes = [])
    {
        $field = new Form\Elements\Input();

        if (count($attributes)) {
            foreach ($attributes as $name => $value) {
                $field->attributes->addAttribute($name, $value);

                if ($name === 'name') {
                    $this->entity->setEntityName('input-' . $value);

                    if ( ! array_key_exists('id', $attributes)) {
                        $field->attributes->setAttributeId('input-' . $value);
                    }
                }
            }
        }

        return $this->input = $field;
    }
578031
public function create(array $attributes)
	{
		if ( ! isset($credentials['permissions']) )
		{
			$credentials['permissions'] = array();
		}

		$group = $this->createModel();
		$group->values($attributes, array('name', 'permissions'));
		$group->save();

		return $group;
	}
21109
public function updateExistingPivot($id, array $attributes, $touch = true)
    {
        if ($this->using && empty($this->pivotWheres) && empty($this->pivotWhereIns)) {
            return $this->updateExistingPivotUsingCustomClass($id, $attributes, $touch);
        }

        if (in_array($this->updatedAt(), $this->pivotColumns)) {
            $attributes = $this->addTimestampsToAttachment($attributes, true);
        }

        $updated = $this->newPivotStatementForId($this->parseId($id))->update(
            $this->castAttributes($attributes)
        );

        if ($touch) {
            $this->touchIfTouching();
        }

        return $updated;
    }
402767
public function create($attributes)
    {
        $attributes = $this->castRequest($attributes);
        $instance   = $this->model->newInstance($attributes);

        event(implode('-', $this->tag).'.entity.creating', [$this, $instance, $attributes]);

        $created = $instance->save();

        event(implode('-', $this->tag).'.entity.created', [$this, $instance, $attributes]);

        return [
            $created,
            $instance,
        ];
    }
52293
public function get_from_ids(array $ids) {
        $alias = $this->get_table_alias();
        list($insql, $params) = $this->get_db()->get_in_or_equal($ids);
        $wheresql = $alias . '.id ' . $insql;
        $sql = $this->generate_get_records_sql($wheresql);
        $records = $this->get_db()->get_records_sql($sql, $params);

        return $this->transform_db_records_to_entities($records);
    }
165283
public function create(array $attributes)
    {
        $instance = $this->related->newInstance($attributes);

        $instance->setAttribute($this->getPlainForeignKey(), $this->getParentKey());

        $instance->save();

        return $instance;
    }
1071734
protected function giveAbilitiesToEveryone(array $ids)
    {
        $attributes = Models::scope()->getAttachAttributes();

        $records = array_map(function ($id) use ($attributes) {
            return ['ability_id' => $id] + $attributes;
        }, $ids);

        Models::query('permissions')->insert($records);
    }
993361
public function create(array $attributes = [])
    {
        return tap($this->related->newInstance($attributes), function ($instance) {
            $foreignKey = $this->getForeignKeyName();
            $parentKeyValue = $this->getParentKey();

            if (is_array($foreignKey)) { //Check for multi-columns relationship
                foreach ($foreignKey as $index => $key) {
                    $instance->setAttribute($key, $parentKeyValue[$index]);
                }
            } else {
                $instance->setAttribute($foreignKey, $parentKeyValue);
            }

            $instance->save();
        });
    }
1018284
public function create($attributes = array())
    {
        $entity = $this->build($attributes);
        $cond = $this->condition();

        // to SQL.
        $sql = $cond->toInsertSQL($attributes);
        var_dump($sql, $cond->getParams());

        // query.
        $sth = $this->query($sql, $cond->getParams());
        if ( $sth->isSuccess() ) {
            $entity->exists = true;
            $entity->setPrimaryValue($sth->lastInsertId());
            return $entity;
        }
    }
482896
public function row(array $attributes = array())
        {
            $row = new self();

            if (count($attributes)) {
                $row->setAttributes($attributes);
            }

            return $row;
        }
1167723
public function create($attributes = [])
    {
        $params = [];

        $params = $this->addPayout($params, $attributes);
        $params = $this->addPayoutMethod($params, $attributes);
        $params = $this->addPayoutBilling($params, $attributes);

        return $this->gateway->commit('post', $this->gateway->buildUrlFromString('payees'), $params);
    }
118318
public function update($id, $attributes)
    {
        $params = [];
        $setStr = "";

        foreach ($attributes as $key => $value) {
            if (!in_array($key, [
                $this->getPrimaryKey(),
                $this->timestampCreatedAt,
                $this->timestampUpdatedAt
            ])
            ) {
                $setStr .= "`" . str_replace("`", "``",
                        $key) . "` = :" . $key . ",";
                $params[':' . $key] = is_array($value) ? json_encode($value) : $value;
            }
        }

        if ($this->timestamps && !is_null($this->timestampUpdatedAt)) {
            $params[':' . $this->timestampUpdatedAt] = date('Y-m-d H:i:s');
            $setStr .= "`" . str_replace("`", "``", $this->timestampUpdatedAt) .
                "` = :" . $this->timestampUpdatedAt . ",";
        }

        $params[':id'] = $id;

        $sql = "UPDATE " . $this->getTable() . " SET " . rtrim($setStr, ',') .
            " WHERE " . $this->getPrimaryKey() . " = :id";

        try {
            $stmt = $this->db->prepare($sql);
            $this->setLastQuery($stmt->queryString, $params);

            $stmt->execute($params);
        } catch (\PDOException $e) {
            throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);

        }

        return $stmt->rowCount();
    }
446666
protected function _create(array $attributes)
    {
        $model = $this->newModelInstance()->forceFill($attributes);

        $model->save();

        return $model;
    }
961501
public function attach($id, array $attributes = [], $touch = true)
    {
        // Here we will insert the attachment records into the pivot table. Once we have
        // inserted the records, we will touch the relationships if necessary and the
        // function will return. We can parse the IDs before inserting the records.
        $this->newPivotStatement()->insert($this->formatAttachRecords(
            $this->parseIds($id), $attributes
        ));

        if ($touch) {
            $this->touchIfTouching();
        }
    }
74331
public function newPivot(array $attributes = [], $exists = false)
    {
        $pivot = $this->related->newPivot(
            $this->parent, $attributes, $this->table, $exists, $this->using
        );

        return $pivot->setPivotKeys($this->foreignPivotKey, $this->relatedPivotKey);
    }