设置属性

@param string $attribute
@param mixed  $value

@return MagicAttributes
320080
public function with($attribute, $value)
    {
        $attribute = $this->snake($attribute);

        if (!$this->validate($attribute, $value)) {
            throw new InvalidArgumentException("错误的属性值'{$attribute}'");
        }

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

        return $this;
    }
949180
private function updateAttribute($attribute, $value)
    {
        if (property_exists($this, $attribute)) {
            $this->$attribute = $value;
        }

        return $this;
    }
1324899
public function setAttr($attribute, $value = null)
    {
        if (is_array($attribute) && is_null($value)) {
            foreach ($attribute as $k => $v) {
                $this->setAttr($k, $v);
            }

            return $this;
        }
        $this->template->appendHTML('attributes', ' '.$attribute.'="'.$value.'"');

        return $this;
    }
68575
public function setAttr($attr, $value = null)
    {
        if (is_array($attr)) {
            $this->attr = array_merge($this->attr, $attr);

            return $this;
        }

        $this->attr[$attr] = $value;

        return $this;
    }
1304880
public function attr($attribute)
    {
        $node = $this->getNode();
        $value = null;

        if ($node instanceof \DOMNode) {
            $value = $node->getAttribute($attribute);
        } else {
            foreach ($node as $item) {
                if ($item->hasAttribute($attribute)) {
                    $value = $node->attr($attribute);
                }

                break;
            }
        }

        return $value;
    }
799210
public function setAttribute($attribute, $value, $scheme = null, $isComputed = false)
    {
        $this->attributes[$attribute] = $value;
        $this->scheme[$attribute] = $scheme;
        $this->is_computed[$attribute] = (true === $isComputed);

        return $this;
    }
617651
public function setAttribute($attribute, $value)
    {
        if(is_null($value)) {
            unset($this->attributes[$attribute]);
        }
        else {
            $this->attributes[$attribute] = $value;
        }

        return $this;
    }
376335
public function setAttribute($key, $value)
    {
        if ($this->hasSetMutator($key)) {
            $method = 'set' .Str::studly($key) .'Attribute';

            return call_user_func(array($this, $method), $value);
        } else if (in_array($key, $this->getDates()) && $value) {
            $value = $this->fromDateTime($value);
        }

        $this->attributes[$key] = $value;
    }
581861
public function attribute($key, $value = null) {
        if (is_array($key)) {
            $this->_attributes = array_replace($this->_attributes, $key);
        } else {
            $this->_attributes[$key] = $value;
        }

        return $this;
    }
86738
public function def($attr, $value)
    {
        $this->attributes[$attr] = isset($this->attributes[$attr]) ? $this->attributes[$attr] : (string) $value;
    }
1366289
public function attribute($attribute, $value = null)
    {
        if (is_array($attribute)) {
            $this->attributes = array_merge($this->attributes, $attribute);
        } else {
            $this->attributes[$attribute] = (string) $value;
        }

        return $this;
    }
1035240
public function with($attribute, $value)
    {
        $this->snakeable && $attribute = Str::snake($attribute);

        $this->setAttribute($attribute, $value);

        return $this;
    }
813901
public function attribute( $attribute, $value )
    {
        if ( null === $value )
        {
            unset( $this->attributes[ $attribute ] );
        } else {
            $this->attributes[ $attribute ] = $value;
        }

        return $this;
    }
789382
public function findBy($attribute, $value, $attributes = ['*'])
    {
        return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($attribute, $value, $attributes) {
            return $this->prepareQuery($this->createModel())->where($attribute, '=', $value)->first($attributes);
        });
    }
816873
public function withAttribute($attribute, $value)
    {
        $new = $this->psrRequest->withAttribute($attribute, $value);
        return new self($new, $this->originalRequest);
    }
385783
public function addAttribute($attribute, $value)
    {
        // Escape special characters
        $value = Filter::filterAttribute($value);

        if ($this->isProperty($attribute)) {
            $this->addPropertyOnDemand($attribute, $value);
        } else {
            if ($this->hasAttribute($attribute)) {
                throw new LogicException(sprintf('The element already has "%s" attribute', $attribute));
            }

            $this->append(sprintf(' %s="%s"', $attribute, $value));
            $this->attributes[$attribute] = $value;
        }

        return $this;
    }
404243
public function filterRecursive($attribute, $value)
    {
        $collection = new Collection();

        // Iterate over all the items in the main collection
        $this->items->each(function ($item) use ($attribute, $value, &$collection) {
            if (!$this->hasProperty($attribute)) {
                return false;
            }

            if ($item->$attribute == $value) {
                $collection->push($item);

                // Check if item has any children
                if ($item->hasChildren()) {
                    $collection = $collection->merge($this->filterRecursive($attribute, $item->id));
                }
            }
        });

        return $collection;
    }