public function updateProduct($input_arr, $tab = 'basic')
 {
     $return_arr = array('status' => false, 'validate_tab_arr' => array());
     if (count($input_arr) > 0) {
         $data_arr = array();
         if ($tab == 'basic') {
             //To remove old category attribute values..
             $product_category_id = Product::whereRaw('id = ?', array($input_arr['id']))->pluck('product_category_id');
             if ($product_category_id != $input_arr['my_category_id']) {
                 $this->productService->removeProductCategoryAttribute($input_arr['id']);
             }
             $data_arr = array('product_name' => $input_arr['product_name'], 'url_slug' => $input_arr['url_slug'], 'product_description' => $input_arr['product_description'], 'product_highlight_text' => $input_arr['product_highlight_text'], 'demo_url' => $input_arr['demo_url'], 'demo_details' => $input_arr['demo_details'], 'product_tags' => $input_arr['product_tags'], 'user_section_id' => $input_arr['user_section_id'], 'product_preview_type' => $input_arr['product_preview_type'], 'product_category_id' => $input_arr['my_category_id'], 'last_updated_date' => \DB::raw('NOW()'));
         } elseif ($tab == 'price') {
             $is_free_product = isset($input_arr['is_free_product']) ? $input_arr['is_free_product'] : 'No';
             $data_arr = array('is_free_product' => $is_free_product);
             if ($is_free_product == 'No') {
                 if ($input_arr['product_discount_price'] > 0) {
                     $from_date = str_replace('/', '-', $input_arr['product_discount_fromdate']);
                     $from_date = date('Y-m-d', strtotime($from_date));
                     $to_date = str_replace('/', '-', $input_arr['product_discount_todate']);
                     $to_date = date("Y-m-d", strtotime($to_date));
                     $data_arr['product_discount_fromdate'] = $from_date;
                     $data_arr['product_discount_todate'] = $to_date;
                 }
                 $site_transaction_fee_type = $input_arr['site_transaction_fee_type'];
                 if (isset($input_arr['global_transaction_fee_used']) && $input_arr['global_transaction_fee_used'] == 'Yes') {
                     $site_transaction_fee_percent = 0;
                     $site_transaction_fee = 0;
                     $global_transaction_fee_used = 'Yes';
                     $site_transaction_fee_type = 'Flat';
                     // To reset default site transaction fee type as Flat
                 } else {
                     $site_transaction_fee_percent = isset($input_arr['site_transaction_fee_percent']) ? $input_arr['site_transaction_fee_percent'] : 0;
                     $site_transaction_fee = isset($input_arr['site_transaction_fee']) ? $input_arr['site_transaction_fee'] : 0;
                     $global_transaction_fee_used = 'No';
                 }
                 $data_arr['site_transaction_fee_type'] = $site_transaction_fee_type;
                 $data_arr['site_transaction_fee'] = $site_transaction_fee;
                 $data_arr['site_transaction_fee_percent'] = $site_transaction_fee_percent;
                 $data_arr['global_transaction_fee_used'] = $global_transaction_fee_used;
                 $data_arr['last_updated_date'] = \DB::raw('NOW()');
                 $data_arr['product_price_currency'] = \Config::get('webshoppack::site_default_currency');
                 //'USD';//$input_arr['product_price_currency'];
                 $data_arr['product_price'] = $input_arr['product_price'];
                 $data_arr['product_price_usd'] = CUtil::convertBaseCurrencyToUSD($input_arr['product_price'], \Config::get('webshoppack::site_default_currency'));
                 $data_arr['product_discount_price'] = $input_arr['product_discount_price'];
                 $data_arr['product_discount_price_usd'] = CUtil::convertBaseCurrencyToUSD($input_arr['product_discount_price'], \Config::get('webshoppack::site_default_currency'));
                 //$data_arr['allow_to_offer'] = isset($input_arr['allow_to_offer'])? $input_arr['allow_to_offer']: 'No';
             }
         } elseif ($tab == 'meta') {
             $data_arr = array('meta_title' => $input_arr['meta_title'], 'meta_keyword' => $input_arr['meta_keyword'], 'meta_description' => $input_arr['meta_description'], 'last_updated_date' => \DB::raw('NOW()'));
         } elseif ($tab == 'attribute') {
             //To delete old attribute values..
             $this->productService->removeProductCategoryAttribute($input_arr['id']);
             $attr_status = $this->productService->addProductCategoryAttribute($input_arr);
             return array('status' => $attr_status, 'validate_tab_arr' => $this->validate_tab_arr);
         } elseif ($tab == 'status') {
             if ($input_arr['product_notes'] != '') {
                 $note_arr = array('product_id' => $input_arr['id'], 'comment' => $input_arr['product_notes']);
                 $c_id = $this->productService->addProductStatusComment($note_arr);
             }
             $data_arr['delivery_days'] = $input_arr['delivery_days'];
             $data_arr['last_updated_date'] = \DB::raw('NOW()');
             //To update status
             if ($input_arr['edit_product'] != '') {
                 if ($input_arr['product_status'] == 'Ok') {
                     $validate_tab_arr = $this->checkProductForPublish($input_arr['id']);
                     if ($validate_tab_arr['allow_to_publish']) {
                         $this->alert_message = 'product_publish_success';
                         $data_arr['product_status'] = $input_arr['product_status'];
                     } else {
                         $this->validate_tab_arr = $validate_tab_arr['tab_arr'];
                     }
                 } else {
                     $this->alert_message = 'products_updated_success_msg';
                     $data_arr['product_status'] = $input_arr['product_status'];
                 }
             }
         } elseif ($tab == 'preview_files') {
             //No need any update for preview tab..
             return array('status' => true, 'validate_tab_arr' => $this->validate_tab_arr);
         }
         if (count($data_arr) > 0) {
             Product::whereRaw('id = ?', array($input_arr['id']))->update($data_arr);
             //To update product status
             if (isset($data_arr['product_status']) && $data_arr['product_status'] == 'Ok') {
                 $product_user_id = Product::whereRaw('id = ?', array($input_arr['id']))->pluck('product_user_id');
                 $this->productService->updateUserTotalProducts($product_user_id);
             }
             //Send mail alert to user for publish and submit for approval products...
             if (isset($data_arr['product_status'])) {
                 if ($data_arr['product_status'] == 'Ok') {
                     //To send published mail, when user publish product at first time
                     $date_activated = Product::whereRaw('id = ?', array($input_arr['id']))->pluck('date_activated');
                     if ($date_activated == '0000-00-00 00:00:00') {
                         //To update prouduct activated date time.
                         Product::whereRaw('id = ?', array($input_arr['id']))->update(array('date_activated' => \DB::raw('NOW()')));
                         $this->productService->sendProductMailToUserAndAdmin($input_arr['id'], $input_arr['product_notes']);
                     }
                 } else {
                     if ($data_arr['product_status'] == 'ToActivate' || $data_arr['product_status'] == 'NotApproved') {
                         $this->productService->sendProductMailToUserAndAdmin($input_arr['id'], $input_arr['product_notes']);
                     }
                 }
             }
             return array('status' => true, 'validate_tab_arr' => $this->validate_tab_arr);
         }
     }
     return $return_arr;
 }