Sync Attribute Dropdown Options
@param \AvoRed\Framework\Models\Database\Attribute $attribute
@param array $data
960764
public function syncDropdownOptions($attribute, $data)
    {
        $dropdownOptionsData = $data['dropdown_options'] ?? [];

        if (count($dropdownOptionsData)) {
            $defaultLanguage = Session::get('default_language');
            $languageId = $data['language_id'] ?? $defaultLanguage->id;

            if ($defaultLanguage->id != $languageId) {
                
                foreach ($dropdownOptionsData as $key => $val) {

                    if (empty($val['display_text'])) {
                        continue;
                    }
                    
                    if (is_int($key)) {
                        $optionModel = AttributeDropdownOption::find($key);
                        
                        $translatedModel = $optionModel
                            ->translations()
                            ->whereLanguageId($languageId)
                            ->first();
                        if (null !== $translatedModel) {
                            $translatedModel->update($val);
                        } else {
                            $optionModel
                                ->translations()
                                ->create(
                                    array_merge($val, ['language_id' => $languageId])
                                );
                        }
                    } 
                }
            } else {
                if ($attribute->attributeDropdownOptions()->get() != null 
                    && $attribute->attributeDropdownOptions()->get()->count() >= 0
                ) {
                    $attribute->attributeDropdownOptions()->delete();
                }

                foreach ($dropdownOptionsData as $key => $val) {
                    if (empty($val['display_text'])) {
                        continue;
                    }
                    $option = $attribute
                        ->attributeDropdownOptions()
                        ->create($val);
                }
            }
        }
    }
1301590
public function setAttribute($attribute, $value): bool
    {
        $this->connect();

        return $this->pdo->setAttribute($attribute, $value);
    }
1146964
private function mapAttributeValues(array $attributes, Attribute $attribute)
    {
        $key = $attribute->getName();
        $value = $attribute->getAllAttributeValues();

        if (!array_key_exists($key, $attributes) && 1 === count($value)) {
            $value = array_shift($value);
        }

        if (array_key_exists($key, $attributes)) {
            $currentValue = (is_array($attributes[$key]) ? $attributes[$key] : [$attributes[$key]]);

            $value = array_merge($currentValue, $value);
        }

        $attributes[$key] = $value;

        return $attributes;
    }
924906
protected function saveProductAttributes($data)
    {
        $attributeWithOptions = isset($data['attribute']) ? $data['attribute'] : [];

        if (count($attributeWithOptions) > 0) {
            $selectedAttributes = isset($data['attribute_selected']) ? $data['attribute_selected'] : [];

            $this->attribute()->sync($selectedAttributes);

            $optionsArray = [];

            foreach ($attributeWithOptions as $attributeId => $attributeOptions) {
                $optionsArray[] = array_values($attributeOptions);
            }

            $listOfOptions = $this->combinations($optionsArray);

            foreach ($listOfOptions as $option) {
                $variationProductData = $this->getVariationProductDataGivenOptions($option);
                $variableProduct = self::create($variationProductData);

                if (isset($data['category_id']) && count($data['category_id']) > 0) {
                    $variableProduct->categories()->sync($data['category_id']);
                }

                if (is_array($option)) {
                    foreach ($option as $attributeOptionId) {
                        $attributeOptionModel = AttributeDropdownOption::findorfail($attributeOptionId);
                        ProductAttributeIntegerValue::create([
                            'product_id' => $variableProduct->id,
                            'attribute_id' => $attributeOptionModel->attribute->id,
                            'value' => $attributeOptionModel->id,
                        ]);
                    }
                } else {
                    $attributeOptionModel = AttributeDropdownOption::findorfail($option);
                    ProductAttributeIntegerValue::create([
                        'product_id' => $variableProduct->id,
                        'attribute_id' => $attributeOptionModel->attribute->id,
                        'value' => $attributeOptionModel->id,
                    ]);
                }

                ProductVariation::create(['product_id' => $this->id,
                    'variation_id' => $variableProduct->id
                ]);
            }
        }
    }
398227
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'type':
            $this->_type = $attribute->nodeValue;
            break;
        case 'lang':
            $this->_lang = $attribute->nodeValue;
            break;
        case 'start':
            $this->_start = $attribute->nodeValue;
            break;
        case 'end':
            $this->_end = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
461287
public function attr($attribute, $value)
    {
        $this->setOption(self::OPTION_METHOD, "attr");
        $this->setOption(self::OPTION_ATTR, $attribute);
        $this->setOption(self::OPTION_VALUE, $value);

        return $this;
    }
1306626
public function setAttribute($attribute, $value)
    {
        switch($attribute){

            case Core::ATTR_AUTO_ACCESSOR_OVERRIDE:
            case Core::ATTR_AUTO_FREE_QUERY_OBJECTS:
            case Core::ATTR_AUTOCOMMIT:
            case Core::ATTR_AUTOLOAD_TABLE_CLASSES:
            case Core::ATTR_CACHE:
            case Core::ATTR_CACHE_LIFESPAN:
            case Core::ATTR_CASCADE_SAVES:
            case Core::ATTR_CASE:
            case Core::ATTR_CLIENT_VERSION:
            case Core::ATTR_CMPNAME_FORMAT:
            case Core::ATTR_COLL_KEY:
            case Core::ATTR_COLL_LIMIT:
            case Core::ATTR_COLLECTION_CLASS:
            case Core::ATTR_CONNECTION_STATUS:
            case Core::ATTR_CREATE_TABLES:
            case Core::ATTR_CURSOR:
            case Core::ATTR_CURSOR_NAME:
            case Core::ATTR_DBNAME_FORMAT:
            case Core::ATTR_DECIMAL_PLACES:
            case Core::ATTR_DEF_TABLESPACE:
            case Core::ATTR_DEF_TEXT_LENGTH:
            case Core::ATTR_DEF_VARCHAR_LENGTH:
            case Core::ATTR_DEFAULT_COLUMN_OPTIONS:
            case Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS:
            case Core::ATTR_DEFAULT_PARAM_NAMESPACE:
            case Core::ATTR_DEFAULT_SEQUENCE:
            case Core::ATTR_DEFAULT_TABLE_CHARSET:
            case Core::ATTR_DEFAULT_TABLE_COLLATE:
            case Core::ATTR_DEFAULT_TABLE_TYPE:
            case Core::ATTR_DRIVER_NAME:
            case Core::ATTR_EMULATE_DATABASE:
            case Core::ATTR_ERRMODE:
            case Core::ATTR_EXPORT:
            case Core::ATTR_FETCH_CATALOG_NAMES:
            case Core::ATTR_FETCH_TABLE_NAMES:
            case Core::ATTR_FETCHMODE:
            case Core::ATTR_FIELD_CASE:
            case Core::ATTR_FKNAME_FORMAT:
            case Core::ATTR_HYDRATE_OVERWRITE:
            case Core::ATTR_IDXNAME_FORMAT:
            case Core::ATTR_LISTENER:
            case Core::ATTR_LOAD_REFERENCES:
            case Core::ATTR_MAX_COLUMN_LEN:
            case Core::ATTR_MAX_IDENTIFIER_LENGTH:
            case Core::ATTR_MODEL_CLASS_PREFIX:
            case Core::ATTR_MODEL_LOADING:
            case Core::ATTR_NAME_PREFIX:
            case Core::ATTR_ORACLE_NULLS:
            case Core::ATTR_PERSISTENT:
            case Core::ATTR_PORTABILITY:
            case Core::ATTR_PREFETCH:
            case Core::ATTR_QUERY_CACHE:
            case Core::ATTR_QUERY_CACHE_LIFESPAN:
            case Core::ATTR_QUERY_CLASS:
            case Core::ATTR_QUERY_LIMIT:
            case Core::ATTR_QUOTE_IDENTIFIER:
            case Core::ATTR_RECORD_LISTENER:
            case Core::ATTR_RECURSIVE_MERGE_FIXTURES:
            case Core::ATTR_RESULT_CACHE:
            case Core::ATTR_RESULT_CACHE_LIFESPAN:
            case Core::ATTR_SEQCOL_NAME:
            case Core::ATTR_SEQNAME_FORMAT:
            case Core::ATTR_SERVER_INFO:
            case Core::ATTR_SERVER_VERSION:
            case Core::ATTR_STATEMENT_CLASS:
            case Core::ATTR_STRINGIFY_FETCHES:
            case Core::ATTR_TABLE_CLASS:
            case Core::ATTR_TABLE_CLASS_FORMAT:
            case Core::ATTR_TBLCLASS_FORMAT:
            case Core::ATTR_TBLNAME_FORMAT:
            case Core::ATTR_THROW_EXCEPTIONS:
            case Core::ATTR_TIMEOUT:
            case Core::ATTR_USE_DQL_CALLBACKS:
            case Core::ATTR_USE_NATIVE_ENUM:
            case Core::ATTR_USE_NATIVE_SET:
            case Core::ATTR_VALIDATE:
                $this->attributes[$attribute] = $value;
                break;

            default:
                throw new Exception("Invalid attribute '{$attribute}'! Must be one of Core::ATTR_* constants.");
        }
    }
639058
protected function addAttributes($element, $data)
    {
        foreach ($data as $attrKey => $attrVal) {
            $element->setAttribute($attrKey, $attrVal);
        }
    }
1296824
public function whereIn($attribute, array $values)
    {
        $this->data->must()->terms($attribute, $values);

        return $this;
    }
192460
public void setAttribute(Attribute attribute) {
		if (!updateMode) {
			originalAttrs.put(attribute);
		}
		else {
			updatedAttrs.put(attribute);
		}
	}
873768
public function setAttributes($attributes, $force = false)
    {
        if ($force) {
            $this->attributes = $attributes;
        } else {
            $this->attributes = array_merge($this->attributes, $attributes);
        }
    }
657013
public function setAttribute($attribute, $value)
    {
        array_set($this->cart->attributes, $attribute, $value);

        $this->update();
    }
415528
public function setNewValue($attribute, $value)
    {
        $this->assertValidAttribute($attribute);

        $this->documentChangeSet[$attribute][1] = $value;
        $this->getDocumentManager()->getUnitOfWork()->setDocumentChangeSet($this->getDocument(), $this->documentChangeSet);
    }
203618
protected function setDataAttributes(Attributes $attributes)
    {
        // add data attributes
        $this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true);

        if (empty($this->bootstrap_dataAttributes)) {
            return;
        }

        foreach ($this->bootstrap_dataAttributes as $attribute) {
            if (trim($attribute['value']) != '' && $attribute['name'] != '') {
                $attributes->setAttribute('data-' . $attribute['name'], $attribute['value']);
            }
        }
    }
1112636
function set($attribute,$value = '')
	{
		if(!is_array($attribute))
		{
			$this->attributes[$attribute] = $value;
		}
		else
		{
			$this->attributes = array_merge($this->attributes,$attribute);
		}
	}
173968
public function removeAttribute($attribute)
    {
        if (in_array(strtolower($attribute), $this->watchedAttributes)) {
            $this->onAttributeChange(strtolower($attribute), null);
        } else {
            self::removeAttributeArray($this->attributes, $attribute);
        }
        return $this;
    }
65313
public function setAttribute(string $attribute)
    {
        if (empty($attribute)) {
            Throw new ColumnException('An empty attribute is not allowed.');
        }

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