setSukAttr($data['suk']); return self::uniqueId($data['product_id'] . $data['suk'] . uniqid(true)); } public static function decProductAttrStock($productId, $unique, $num) { return false !== self::where('product_id', $productId)->where('unique', $unique) ->dec('stock', $num)->inc('sales', $num)->update(); } public static function uniqueId($key) { return substr(md5($key), 12, 8); } public static function clearProductAttrValue($productId) { return self::where('product_id', $productId)->delete(); } }