Set an attribute defined by key. If the key does not point to a relation,
pass the value through a mutator and set a changed flag.

@param string $key
@param mixed $value
@return $this
518530
public function set($key, $value = null) {

        // Do not trigger state changes for relations
        if (!$this->hasRelation($key)) {

            // Only flag changed if the value is different
            if ($value != $this->get($key) && !in_array($key, $this->reserved)) {
                $this->_changed = true;
            }

            // Run the value through a mutator but do not set the mutator key
            if ($method = $this->hasMutator($key)) {
                $this->{$method}($value);

                return $this;
            }
        }

        $this->_attributes[$key] = $value;

        return $this;
    }
2780
public function setAttribute($key, $value)
    {
        if ($value !== null && $this->hasEnumCast($key)) {
            $enum = $this->enumCasts[$key];

            if ($value instanceOf $enum) {
                $this->attributes[$key] = $value->value;
            } else {
                $this->attributes[$key] = $enum::getInstance($value)->value;
            }

            return $this;
        }

        parent::setAttribute($key, $value);
    }
1110799
public function setAttribute(string $key, string $value)
    {
        if ($this->valid($key, $value)) {
            $value = encrypt($value);
        }

        return parent::setAttribute($key, $value);
    }
734781
public function set(string $key, $value): Definition
    {
        $this->data[$key] = $value;

        return $this;
    }
1235721
public function setAttribute($key, $value)
    {
        if (in_array($key, $this->getTranslatable())) {
            $translation = $this->translateOrNew($this->getLocale());

            $translation->$key = $value;

            $this->translationCache[$this->getLocale()] = $translation;

            return $translation;
        }

        return parent::setAttribute($key, $value);
    }
50238
protected function setAttribute($key, $value)
    {
        if (is_null($value)) {
            $this->attributes[$key] = null;

            return $this;
        }

        if (in_array($this->getKeyType($key), ['json', 'datetime', 'tags'])) {
            $this->attributes[$key] = $this->cast($this->getKeyType($key), $value);

            return $this;
        }

        if ($this->getKeyType($key) === 'relation') {
            $this->attributes[$key] = new self((array) $value);

            return $this;
        }

        if ($this->getKeyType($key) === 'media') {
            $this->attributes[$key] = new AssetFile((array) $value);

            return $this;
        }

        if ($this->getKeyType($key) === 'relation') {
            $this->attributes[$key] = new self((array) $value);

            return $this;
        }

        $this->attributes[$key] = $value;

        return $this;
    }
1109932
public function setAttribute($key, $value)
    {
        if ($value !== null && $this->isSerializeCastable($key)) {
            $value = $this->asSerialize($value);
        }

        return parent::setAttribute($key, $value);
    }
1035902
protected function mutateAttribute($key, $value)
    {
        $method = 'get' .Str::studly($key) .'Attribute';

        return call_user_func(array($this, $method), $value);
    }
610032
public function setAttribute($key, $value)
    {
        // Verificar alias para _id
        $key = ($key == 'id') ? '_id' : $key;

        // First we will check for the presence of a mutator for the set operation
        // which simply lets the developers tweak the attribute as it is set on
        // the model, such as "json_encoding" an listing of data for storage.
        if ($this->hasSetMutator($key)) {
            $this->changed[$key] = true;

            return $this->setMutateAttribute($key, $value);
        }

        // Verificar se foi definido o cast do key
        if ($this->hasCast($key)) {
            $value = $this->setCast($key, $value);
        }

        return $this->setAttributeToArray($key, $value);
    }
48819
protected function mutateAttributeForArray($key, $value)
    {
        if ($this->hasMapping($key)) {
            $value = $this->mapAttribute($key);

            return $value instanceof Arrayable ? $value->toArray() : $value;
        }

        return parent::mutateAttributeForArray($key, $value);
    }
531164
public function setAttribute($key, $value)
    {
        $key = strtolower($key);
        if ( ! is_array($value)) {
            $value = [
                'value'       => $value,
                'doubleQuote' => true,
            ];
        }
        $this->attr[$key] = $value;

        return $this;
    }
673930
public function setOption($key, $value)
    {

        $this->getTargetConfigurableObject()
            ->setOption($this->getOptionName($key), $value);

        return $this;
    }
8792
public function setAttribute($attribute, $value){
        if($attribute === 'table'){
            $this->_table = $value;
        }
        elseif($attribute === 'pk'){
            $this->_pk = $value;
        }
        elseif($attribute === 'relations'){
            $this->_relations = $value;
        }
        
        return $this;
    }
181601
public function set($key, $value = null)
    {
        $key = $this->resolveAlias($key);

        $mutator = 'set' . $this->toCamelCase($key) . 'Value';

        if (is_callable([$this, $mutator])) {
            $this->$mutator($value);
        } else {
            $this->data[$key] = $value;
        }

        return $this;
    }
599236
public function with($key, $value = null)
    {
        if (is_array($key)) {
            $this->attributes = array_merge($this->attributes, $key);
        } else {
            $this->attributes[$key] = $value;
        }

        return $this;
    }
1105945
public function setAttribute( $key, $value )
	{
		if( $this->getAttribute( $key ) === (string) $value )
			return FALSE;
		$this->attributes[$key] = (string) $value;
		return TRUE;
	}
1368217
public function setAttribute($key, $value = null)
    {
        if (is_array($key) && is_null($value)) {
            $this->attributes = $key;
        } else {
            array_set($this->attributes, $key, $value);
        }

        return $this;
    }