public function updatingListProducts($data) { //pr($data); $productModel = new Product(); foreach ($data as $key => &$element) { if (isset($element['GK.site_id'])) { $check = $productModel->comparePrice('GK', $key, isset($element['GK.enabled']) ? $element['GK.enabled'] : null, isset($element['GK.yandex_enabled']) ? $element['GK.yandex_enabled'] : null, isset($element['GK.price']) ? addComma($element['GK.price']) : null, isset($element['GK.currency']) ? $element['GK.currency'] : null); if ($check) { $element['GK.to_export'] = 1; } } if (isset($element['TV.site_id'])) { $check = $productModel->comparePrice('TV', $key, isset($element['TV.enabled']) ? $element['TV.enabled'] : null, isset($element['TV.yandex_enabled']) ? $element['TV.yandex_enabled'] : null, isset($element['TV.price']) ? addComma($element['TV.price']) : null, isset($element['TV.currency']) ? $element['TV.currency'] : null); if ($check) { $element['TV.to_export'] = 1; } } if (isset($element['MK.site_id'])) { $check = $productModel->comparePrice('MK', $key, isset($element['MK.enabled']) ? $element['MK.enabled'] : null, isset($element['MK.yandex_enabled']) ? $element['MK.yandex_enabled'] : null, isset($element['MK.price']) ? addComma($element['MK.price']) : null, isset($element['MK.currency']) ? $element['MK.currency'] : null); if ($check) { $element['MK.to_export'] = 1; } } $this->leftJoin('price_GK as GK', 'products.id', '=', 'GK.product_id')->leftJoin('price_TV as TV', 'products.id', '=', 'TV.product_id')->leftJoin('price_MK as MK', 'products.id', '=', 'MK.product_id')->where('products.id', $key)->update($element); } /*pr($data,true);*/ }