Set the model position in the database.

@param array $attributes

@return \Subbly\Model\Category
542379
final public function sort(array $attributes = array())
    {
        $category       = $this->find($attributes['movingId']);
        $positionEntity = $this->find($attributes['movedId']);

        if ($category instanceof Category) {
            if ($this->fireEvent('sorting', array($category)) === false) {
                return false;
            }

            $category->setCaller($this);
            $category->{$attributes['type']}($positionEntity);

            $this->fireEvent('sorted', array($category));

            return $category;
        }

        throw new Exception(sprintf(Exception::CANT_UPDATE_MODEL,
            'Subbly\\Model\\Category',
            $this->name()
        ));
    }
424218
public function setAttributeArray(array $attributes = null)
    {
        if (!is_array($attributes) || empty($attributes)) {
            return;
        }

        foreach ($attributes as $name => $value) {
            $this->setAttribute($name, $value);
        }
    }
385079
public function make(array $attributes = [])
    {
        $model = $this->model->newInstance($attributes);
        $this->publish('made', $model);

        return $model;
    }
569354
public function firstOrCreate(array $attributes = [])
    {
        $this->applyCriteria();
        $this->applyScope();

        $model = $this->model->firstOrCreate($attributes);
        $this->resetModel();

        return $this->parserResult($model);
    }
845151
public function fill( array $attributes ) {
		foreach ( $attributes as $key => $value ) {
			if ( ! array_key_exists( $key, $this->attributes ) ) {
				continue;
			}

			$this->set_attribute( $key, $value );
		}

		return $this;
	}
827246
public function firstOrCreate( array $attributes )
	{
		if ( !is_null( $instance = $this->where( $attributes )->first() ) )
			return $instance;

		$instance = $this->model->newInstance( $attributes );

		$instance->save();

		return $instance;
	}
63081
public function setAttributes(array $attributes = null)
    {
        $this->attributes = array_merge($this->attributes, $attributes);
        return $this;
    }
521383
public function setAttributes($attributes)
    {
        foreach ($attributes as $key => $string_values) {
            $values = explode(' ', $string_values);

            // Trim the values
            $values = array_map('trim', $values);
            // Remove empty elements
            $values = array_filter($values);
            // Remove duplicate values
            $values = array_unique($values);

            $this->attributes[$key] = $values;
        }

        return $this;
    }
1030366
public function firstOrNew(array $attributes = [])
    {
        $this->applyCriteria();
        $this->applyScope();

        $model = $this->model->firstOrNew($attributes);
        $this->resetModel();

        return $this->parserResult($model);
    }
653230
public function add(array $attributes = array())
    {
        if (!$this->contains($attributes)) {
            $this->model->getModel()->newInstance($attributes)->save();
            $this->cache->forget($this->cacheKey);
        }
        return $this;
    }
701122
public function store(array $attributes)
    {
        $model = $this->make([]);

        $this->validate($attributes, 'store');

        $this->fillModel($model, $attributes);
        $this->fire($this->event('storing'), [$model, $attributes]);
        $model->save();
        $this->fire($this->event('stored'), [$model, $attributes]);
        return $model;
    }
141426
public function fill(array $attributes)
	{
		$totallyGuarded = $this->totallyGuarded();

		foreach ($this->fillableFromArray($attributes) as $key => $value)
		{
			$key = $this->removeTableFromKey($key);

			// The developers may choose to place some attributes in the "fillable"
			// array, which means only those attributes may be set through mass
			// assignment to the model, and all others will just be ignored.
			if ($this->isFillable($key))
			{
				$this->setAttribute($key, $value);
			}
			elseif ($totallyGuarded)
			{
				throw new MassAssignmentException($key);
			}
		}

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

        $model->save();

        return $model;
    }
1259588
public function addAttributes(array $attributes)
    {
        foreach ($attributes as $attribute => $value) {
            $this->addAttribute($attribute, $value);
        }

        return $this;
    }
786770
public function tableAttributes(array $attributes = array()): Builder
    {
        array_set($attributes, 'id', array_get($attributes, 'id') . str_random(3));
        $this->tableAttributes = array_merge($this->tableAttributes, $attributes);
        return $this;
    }
755629
public function setChildrenAttributes($attributes)
    {
        if (! is_array($attributes)) {
            $attributes = [$attributes];
        }

        $this->children_attributes = $attributes;

        return $this;
    }
837863
final public function sort(array $attributes = array())
    {
        $product        = $this->find($attributes['movingId']);
        $positionEntity = $this->find($attributes['movedId']);

        if ($product instanceof Product) {
            if ($this->fireEvent('sorting', array($product)) === false) {
                return false;
            }

            $product->setCaller($this);
            $product->{$attributes['type']}($positionEntity);

            $this->fireEvent('sorted', array($product));

            return $product;
        }

        throw new Exception(sprintf(Exception::CANT_UPDATE_MODEL,
            'Subbly\\Model\\Product',
            $this->name()
        ));
    }