public function getAttributeValue($p_id, $attr_id, $attr_type, $dafault_value) { switch ($attr_type) { case 'text': case 'textarea': $count = ProductAttributesValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->count(); if ($count > 0) { return ProductAttributesValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->pluck('attribute_value'); } break; case 'select': case 'option': // radio button // radio button case 'multiselectlist': case 'check': // checkbox $count = ProductAttributesOptionValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->count(); if ($count > 0) { $rtn_arr = array(); $t_arr = ProductAttributesOptionValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->get(array('attribute_options_id'))->toArray(); foreach ($t_arr as $arr) { $rtn_arr[] = $arr['attribute_options_id']; } return $rtn_arr; } break; } return $dafault_value; }
public function isAttributeOptionsUsed($attribute_option_id) { $option_used = false; // check attribute options used in items $attr_option_count = ProductAttributesOptionValues::whereRaw('attribute_options_id = ?', array($attribute_option_id))->count(); if ($attr_option_count > 0) { $option_used = true; } return $option_used; }