Attach a model to the parent.

@param  mixed  $id
@param  array  $attributes
@param  bool   $touch
@return void
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();
        }
    }
1041532
public function store( $id, $data, $attributes = array() )
    {
        $this->forceStoreRegistry = true;
        $storeResult = parent::store( $id, $data, $attributes );

        // Update clustered expiry timestamp
        $expiryTime = time() + $this->properties['options']['ttl'];
        $this->expiryHandler->setTimestamp( ezpRestRouter::ROUTE_CACHE_KEY, $expiryTime );

        return $storeResult;
    }
1023654
public function update($id, $attributes)
    {
        $attributes = $this->castRequest($attributes);
        $updated    = false;
        $instance   = $id instanceof Model ? $id : $this->find($id);

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

            $updated = $instance->update($attributes);

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

        return [
            $updated,
            $instance,
        ];
    }
744726
public function sync($attributes)
    {
        if (isset($attributes['$id'])) {
            $this->state = static::STATE_ATTACHED;
            $this->id = $attributes['$id'];
        } else {
            foreach ($this->schema() as $key => $field) {
                if ($field->has('default')) {
                    $attributes[$key] = $field['default'];
                }
            }

            $this->state = static::STATE_DETACHED;
        }

        $this->set($attributes);
        $this->populateOld();
    }
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;
    }
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;
    }
578153
public function setAttributes(array $attributes): void
    {
        $this->checkAttributeAssignable(array_keys($attributes));

        $this->setRawAttributes($attributes);
    }
971645
public function detach($id, $relation, $attributes)
    {
        return $this->find($id)->{$relation}()->detach($attributes);
    }
97393
protected function move($id, $parentId, $left, $right)
    {
        $instance = $this->repository->find($id);

        $attributes = $instance->getAttributes();
        $attributes[$this->getLeftColumn($instance)] = $left;
        $attributes[$this->getRightColumn($instance)] = $right;
        $attributes[$this->getParentColumn($instance)] = $parentId;

        $instance->setRawAttributes($attributes);
        $instance->save();
    }
758200
def attach(self, id, attributes=None, touch=True):
        
        if isinstance(id, orator.orm.Model):
            id = id.get_key()

        query = self.new_pivot_statement()

        if not isinstance(id, list):
            id = [id]

        query.insert(self._create_attach_records(id, attributes))

        if touch:
            self.touch_if_touching()
929520
public function setId($id)
    {
        if (is_null($this->id) && ! is_null($id) && ($model = $this->getRepository()->find($id))) {
            $this->id = $id;

            parent::setModel($model);
            $this->getButtons()->setModel($model);
            $this->setModelClass(get_class($model));
        }
    }
12644
private function sync($id, $attributes)
    {
        // Return if the ID is invalid, or attributes is not an array
        if (!isset($id) || !isset($attributes) || empty($attributes)) {
            return $this;
        }

        // Return if there are no relationships of that type
        if (!isset($this->relationships['belongsToMany']) || empty($this->relationships['belongsToMany'])) {
            return $this;
        }

        // Sync each relationship
        foreach ($this->relationships['belongsToMany'] as $join) {

            // The sync option has to be true, the related attribute an array
            if (isset($join['sync']) && $join['sync'] && isset($attributes[$join['alias']]) && is_array($attributes[$join['alias']])) {

                // Delete old values
                $delete = $this->db()->table($join['pivot'])->where($join['localKey'], $id, '=')->delete();

                // Insert new values
                foreach ($attributes[$join['alias']] as $value) {
                    $this->db()->table($join['pivot'])->insert([$join['localKey'] => $id, $join['foreignKey'] => $value]);
                }
            }
        }

        // Return model instance
        return $this;
    }
443482
private function processClip($id,$attributes,$offset)
	{
		return $this->processBeginClip($id,$attributes,$offset) . $this->processEndClip($id,$offset);
	}
65399
public function updateOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true)
    {
        if (is_null($instance = $this->where($attributes)->first())) {
            return $this->create($values, $joining, $touch);
        }

        $instance->fill($values);

        $instance->save(['touch' => false]);

        return $instance;
    }
1369129
protected function touchRelated(): void
	{
		foreach($this->getRelationsToTouch() as $touch)
		{
			$touch = explode('.', $touch);

			$relation = $this->{array_shift($touch)}();

			foreach($touch as $nested)
			{
				$related = $relation->first();

				if($related === false)
				{
					continue 2;
				}

				$relation = $related->$nested();
			}

			$relation->update([$relation->getModel()->getUpdatedAtColumn() => null]);
		}
	}
1066183
public function detach($id = array(), $touch = true) {
        if (!$id instanceof Model and ! $id instanceof Collection) {
            $id = $this->modelsFromIds($id);
        } elseif (!is_array($id)) {
            $id = [$id];
        }

        // Prepare for a batch operation to take place so that we don't
        // overwhelm the database with many delete hits.
        $this->finder->prepareBatch();

        foreach ($id as $model) {
            $edge = $this->edge($model);
            $edge->delete();
        }

        $results = $this->finder->commitBatch();

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

        return $results;
    }
63753
public function attach($ids, array $attributes = [], $touch = true)
    {
        list($idsOnly, $idsAttributes) = $this->getIdsWithAttributes($ids, $attributes);

        $this->parent->fireModelEvent('pivotAttaching', true, $this->getRelationName(), $idsOnly, $idsAttributes);
        $parentResult = parent::attach($ids, $attributes, $touch);
        $this->parent->fireModelEvent('pivotAttached', false, $this->getRelationName(), $idsOnly, $idsAttributes);

        return $parentResult;
    }