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; }
public function getProductCategoryAttributeValue($p_id, $product_category_id) { $input_arr = array(); $attr_arr = $this->getAttributesList($product_category_id); foreach ($attr_arr as $key => $val) { $id = $val['attribute_id']; $key = 'attribute_' . $id; if ($val['validation_rules'] != '') { $attr_type = $val['attribute_question_type']; switch ($attr_type) { case 'text': case 'textarea': $input_arr[$key] = ProductAttributesValues::whereRaw('product_id = ? AND attribute_id = ?', array($p_id, $id))->pluck('attribute_value'); break; case 'select': case 'option': // radio button // radio button case 'multiselectlist': case 'check': // checkbox $option_val = ProductAttributesOptionValues::whereRaw('product_id = ? AND attribute_id = ?', array($p_id, $id))->get(array('attribute_options_id')); foreach ($option_val as $option) { $input_arr[$key][] = $option->attribute_options_id; } break; } } } return $input_arr; }