public function removeProductCategoryAttribute() { //To delete product attributes values ProductAttributesValues::whereRaw("product_id = ?", array($this->product_id))->delete(); //To delete product attributes options values ProductAttributesOptionValues::whereRaw("product_id = ?", array($this->product_id))->delete(); }
public function isOptionsAlreadyUsed($attribute_id) { $attribute_used = false; // check attribute options used in items $attr_option_count = ProductAttributesOptionValues::whereRaw('attribute_id = ?', array($attribute_id))->count(); if ($attr_option_count > 0) { $attribute_used = true; } else { // check attributes without options like textbox/textarea used in items $attr_values_count = ProductAttributesValues::whereRaw('attribute_id = ?', array($attribute_id))->count(); if ($attr_values_count > 0) { $attribute_used = true; } } return $attribute_used; }