Creates a node field

@param int $id
@param array $attributes
@return NodeFieldContract
186175
public function create($id, array $attributes)
    {
        $typeModelName = $this->getTypeModelName();

        $nodeType = $typeModelName::findOrFail($id);

        $nodeField = $nodeType->addField($attributes);

        $this->builderService->buildField(
            $nodeField->getName(),
            $nodeField->getType(),
            $nodeField->isIndexed(),
            $nodeType->getName(),
            $nodeType
        );

        return $nodeField;
    }
1190822
protected function createAttachRecords($ids, array $attributes)
    {
        $records = [];

        $timed = in_array($this->createdAt(), $this->pivotColumns);

        // 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;
    }
319424
public function removeField($id)
    {
        if (isset($this->_fields[$id])) {
            $name = $this->_fields[$id]->getName();
            unset($this->_fields[$id], $this->_fieldNameMap[$name]);
        }
        return $this;
    }
739165
public function createInput(array $attributes = [])
    {
        $field = new Components\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);
                    }
                }
            }
        }

        $this->childNodes->push($field);

        return $this->childNodes->last();
    }
837376
public function attach($id, array $attributes = [])
    {
        $query = $this->newPivotStatement();

        $query->insert($this->createAttachRecords((array) $id, $attributes));
    }
182554
public function addField(array $attributes)
    {
        $field = $this->fields()->create($attributes);

        $this->save();

        return $field;
    }
634194
public function update($id, array $attributes)
    {
        $user = $this->findById($id);

        $user->first_name = $attributes['first_name'];
        $user->last_name = $attributes['last_name'];
        $user->email = $attributes['email'];
        $user->permissions = $attributes['permissions'];

        if( array_key_exists('password', $attributes) )
        {
            $user->password = $attributes['password'];
        }

        $user->save();

        if ( array_key_exists('groups',$attributes) )
        {
            $this->syncGroups($attributes['groups'], $user);
        }

        $this->event->fire('users.update',array($user));

        return $user;
    }
81979
public function store( $id, $data, $attributes = array() )
    {
        if ( !isset( $this->clusterCacheFile ) )
        {
            $this->clusterCacheFile = eZClusterFileHandler::instance(
                $this->properties['location'] . $this->generateIdentifier( $id, $attributes )
            );
        }

        $this->clusterCacheFile->storeCache(
            array(
                'scope'        => 'rest-cluster-cache',
                'binarydata'   => $this->prepareData( $data )
            )
        );

        return $id;
    }
936223
protected function addLabelAttributes(array $attributes, $id)
    {
        $attributes = $this->addAttribute($attributes, 'for', $id);
        if (empty($id)) {
            $attributes = $this->addAttribute($attributes, 'class', $this->multiLabelClass);
        }
        return $attributes;
    }
1253569
public function attach($id, array $attributes = array(), $touch = true)
    {
        $models = $id;

        if ($id instanceof Model)
        {
            $models = [$id];
        } elseif ($id instanceof Collection)
        {
            $models = $id->all();
        } elseif ( ! $this->isArrayOfModels($id))
        {
            $models = $this->modelsFromIds($id);
            // In case someone is messing with us and passed a bunch of ids (or single id)
            // that do not exist we slap them in the face with a ModelNotFoundException.
            // There must be at least a record found as for the records that do not match
            // they will be ignored and forever forgotten, poor thing.
            if (count($models) < 1) throw new ModelNotFoundException;

            $models = $models->all();
        }

        $saved = $this->saveMany($models, $attributes);

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

        return ( ! is_array($id)) ? $saved->first() : $saved;
    }
1319740
protected function setFieldValue($id)
    {
        $relations = $this->getRelations();

        $this->model = $this->model->with($relations)->findOrFail($id);

//        static::doNotSnakeAttributes($this->model);

        $data = $this->model->toArray();

        $this->builder->fields()->each(function (Field $field) use ($data) {
            $field->fill($data);
        });
    }
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;
        }
    }
702578
public function generateIdentifier( $id, $attributes = null )
    {
        $identifier = strtolower( $this->backendName )
            . $this->properties['location']
            . $id 
            . (
                ( $attributes !== null && !empty( $attributes ) ) 
                ? md5( serialize( $attributes ) ) 
                : ''
        );
        return urlencode( $identifier );
    }
1367112
protected function addCdataNode($nodeName, $value, array $attributes = array())
    {
        // create element
        $domElement = $this->getDomElement()->ownerDocument->createElement($nodeName);
        $this->getDomElement()->appendChild($domElement);

        // create cdata
        $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value);
        $domElement->appendChild($cdata);

        // add attributes
        foreach ($attributes as $attributeId => $attributeValue) {
            $domElement->setAttribute($attributeId, $attributeValue);
        }

        return $this;
    }
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;
	}
1135198
public function update($id = null, $attributes = [])
    {
        // ID has to be defined
        if (!isset($id)) {
            throw new \InvalidArgumentException('Undefined ID to update', 400);
        }

        // Attributes have to be array
        if (!(isset($attributes)) || !is_array($attributes)) {
            throw new \InvalidArgumentException('Undefined attributes', 400);
        }

        // Perform before hook
        $attributes = $this->beforeUpdate($id, $attributes);

        // Remove non fillable attributes
        $fields = array_intersect_key($attributes, array_flip($this->fillable));

        // Validate attributes
        $this->setValidationRules();
        $errors = $this->validationErrors($fields);
        if ($errors) {
            throw new Exceptions\ValidationException('Invalid attributes', 400, $errors);
        }

        // Update the model
        if ($fields && count($fields)) {
            $result = $this->db()->table($this->table)->where($this->primaryKey, $id, '=', $this->table)->update($fields);

            // Return false if the update failed
            if (!$result) {
                throw new \Exception('Could not update the model', 500);
            }
        }

        // Sync many to many relationships
        $this->sync($id, $attributes);

        // Upsert has many relationships
        $this->updateHasMany($id, $attributes);

        // Get the created model
        $model = $this->find($id);

        // Run after hook
        $model = $this->afterUpdate($id, $attributes, $model);

        // Return the created model
        return $model;
    }
531049
public function create($tag = 'div', $value = null, $attributes = [])
    {
        if (is_array($value)) {
            $attributes = $value;
            $value      = null;
        }

        $content = '<'.$tag.$this->attributes($attributes).'>';

        if (! is_null($value)) {
            $content .= $this->entities($value).'</'.$tag.'>';
        }

        return $this->raw($content);
    }