public function dailyspecialDetails(Request $request)
 {
     $postData = $request->all();
     $response = new stdClass();
     $objUserModel = new User();
     if ($postData) {
         $userId = '';
         if (isset($postData['id'])) {
             $userId = $postData['id'];
         }
         $mytoken = '';
         $authflag = false;
         if (isset($postData['mytoken'])) {
             $mytoken = $postData['mytoken'];
             if ($mytoken == env("API_TOKEN")) {
                 $authflag = true;
             } else {
                 if ($userId != '') {
                     $whereForloginToken = $userId;
                     DB::setFetchMode(PDO::FETCH_ASSOC);
                     $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                     if ($mytoken == $Userscredentials['login_token']) {
                         $authflag = true;
                     }
                 }
             }
         }
         if ($authflag) {
             //LOGIN TOKEN
             DB::setFetchMode(PDO::FETCH_ASSOC);
             $objCampaingsModel = new Campaigns();
             $dailyDetails = $objCampaingsModel->getDailyspecialDetail();
             if ($dailyDetails) {
                 $data = $dailyDetails;
                 $response->code = 200;
                 $response->message = "Success";
                 $response->data = $data;
             } else {
                 $response->code = 100;
                 $response->message = "Something went Wrong. No Product Details found.";
                 $response->data = null;
             }
         } else {
             $response->code = 401;
             $response->message = "Access Denied";
             $response->data = null;
         }
     } else {
         $response->code = 401;
         $response->message = "Invalid request";
         $response->data = null;
     }
     echo json_encode($response, true);
 }
 public function flashsaleDetails(Request $request)
 {
     $postData = $request->all();
     $response = new stdClass();
     $objUserModel = new User();
     if ($postData) {
         $userId = '';
         if (isset($postData['id'])) {
             $userId = $postData['id'];
         }
         $mytoken = '';
         $authflag = false;
         if (isset($postData['mytoken'])) {
             $mytoken = $postData['mytoken'];
             if ($mytoken == env("API_TOKEN")) {
                 $authflag = true;
             } else {
                 if ($userId != '') {
                     $whereForloginToken = $userId;
                     DB::setFetchMode(PDO::FETCH_ASSOC);
                     $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                     if ($mytoken == $Userscredentials['login_token']) {
                         $authflag = true;
                     }
                 }
             }
         }
         if ($authflag) {
             //LOGIN TOKEN
             DB::setFetchMode(PDO::FETCH_ASSOC);
             $objCampaingsModel = new Campaigns();
             $objProductCategoryModel = new ProductCategories();
             $objProductsModel = new Products();
             $currenttime = time();
             $campaignDetails = $objCampaingsModel->getFlashsaleDetail();
             if ($campaignDetails) {
                 //            foreach ($campaignDetails as $campaignkey => $campaignval) {
                 //                $productcategoryId = array($campaignval['for_category_ids']);
                 //                $productproductId = array($campaignval['for_product_ids']);
                 //
                 //            }
                 //            $categoryId = explode(",", $productcategoryId[0]);
                 //            $productId = explode(",", $productproductId[0]);
                 //            if ($categoryId != '' && $productId != '') {
                 //                $category = $objProductCategoryModel->getCategoriesWhere($categoryId);
                 //                $products = $objProductsModel->getProductWhere($productId);
                 $data = $campaignDetails;
                 //                $data['categoryId'] = $category;
                 //                $data['productId'] = $products;
                 $response->code = 200;
                 $response->message = "Success";
                 $response->data = $data;
             } else {
                 $response->code = 100;
                 $response->message = "Something went Wrong. No Product Details found.";
                 $response->data = null;
             }
         } else {
             $response->code = 401;
             $response->message = "Access Denied";
             $response->data = null;
         }
     } else {
         $response->code = 401;
         $response->message = "Invalid request";
         $response->data = null;
     }
     echo json_encode($response, true);
 }
 /**
  * Flashsale Ajax Handler
  * @param Request $request
  * @author: Vini Dubey<*****@*****.**>
  */
 public function flashsaleAjaxHandler(Request $request)
 {
     $method = $request->input('method');
     $objUserModel = new User();
     $objCategoryModel = ProductCategories::getInstance();
     $objProductModel = Products::getInstance();
     $objOptionVariant = ProductOptionVariants::getInstance();
     $objCampaigns = Campaigns::getInstance();
     if ($method != "") {
         switch ($method) {
             case 'optionVariantDetails':
                 $postData = $request->all();
                 $response = new stdClass();
                 if ($postData) {
                     $userId = '';
                     if (isset($postData['id'])) {
                         $userId = $postData['id'];
                     }
                     $productId = '';
                     if (isset($postData['variant_id'])) {
                         $variantId = $postData['variant_id'];
                     }
                     if (isset($postData['product_id'])) {
                         $productId = $postData['product_id'];
                     }
                     if (isset($postData['selectedCombination'])) {
                         $selectedCombination = $postData['selectedCombination'];
                     }
                     $mytoken = '';
                     $authflag = false;
                     if (isset($postData['api_token'])) {
                         $mytoken = $postData['api_token'];
                         if ($mytoken == env("API_TOKEN")) {
                             $authflag = true;
                         } else {
                             if ($userId != '') {
                                 $whereForloginToken = $userId;
                                 $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                                 if ($mytoken == $Userscredentials['login_token']) {
                                     $authflag = true;
                                 }
                             }
                         }
                     }
                     $variantDetails = '';
                     if ($authflag) {
                         $where = ['rawQuery' => 'product_option_variants_combination.product_id = ? AND product_option_variants_combination.variant_ids IN("' . $selectedCombination . '","' . strrev($selectedCombination) . '")', 'bindParams' => [$productId]];
                         $selectedColumn = ['product_option_variants.*', 'product_images.*', 'product_option_variants_combination.*', 'product_option_variant_relation.*', DB::raw('GROUP_CONCAT(
                 CASE
                 WHEN ((SELECT COUNT(pi_id) FROM product_images  WHERE product_images.for_combination_id !="0")!=0)
                 THEN
                     CASE
                         WHEN (product_images.image_type =1 AND (product_images.for_combination_id!=0 OR product_images.for_combination_id!=""))
                         THEN product_images.image_type
                      END
                  ELSE  product_images.image_type
                 END) AS image_types'), DB::raw('GROUP_CONCAT(DISTINCT
                 CASE
                 WHEN ((SELECT COUNT(pi_id) FROM product_images  WHERE product_images.for_combination_id !="0")!=0)
                 THEN
                     CASE
                         WHEN (product_images.image_type =1 AND (product_images.for_combination_id!=0 OR product_images.for_combination_id!=""))
                         THEN product_images.image_url
                      END
                  ELSE  product_images.image_url
                 END) AS image_urls'), DB::raw('GROUP_CONCAT(DISTINCT product_option_variants_combination.variant_ids) AS variant_ids_combination'), DB::raw('GROUP_CONCAT(DISTINCT product_option_variant_relation.variant_ids) AS variant_id')];
                         $optionVariantDetailsForPopUp = $objOptionVariant->getOptionVariantDetailsForPopup($where, $selectedColumn);
                         //  echo'<pre>';print_r($optionVariantDetailsForPopUp);die("fchb");
                         if ($optionVariantDetailsForPopUp[0]) {
                             $response->code = 200;
                             $response->message = "Success";
                             $response->data = $optionVariantDetailsForPopUp[0];
                         } else {
                             $response->code = 100;
                             $response->message = "Something went Wrong. No Product Details found.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
             case 'getCampaignsForMenu':
                 $postData = $request->all();
                 $response = new stdClass();
                 if ($postData) {
                     $userId = '';
                     if (isset($postData['id'])) {
                         $userId = $postData['id'];
                     }
                     $mytoken = '';
                     $authflag = false;
                     if (isset($postData['api_token'])) {
                         $mytoken = $postData['api_token'];
                         if ($mytoken == env("API_TOKEN")) {
                             $authflag = true;
                         } else {
                             if ($userId != '') {
                                 $whereForloginToken = $userId;
                                 $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                                 if ($mytoken == $Userscredentials['login_token']) {
                                     $authflag = true;
                                 }
                             }
                         }
                     }
                     $variantDetails = '';
                     if ($authflag) {
                         $where = ['rawQuery' => 'available_from < ? AND available_upto > ? AND campaign_status = ?', 'bindParams' => [time(), time(), 1]];
                         $selectedColumns = ['Campaigns.*'];
                         $campaignDetails = $objCampaigns->getFlashsaleDetail($where, $selectedColumns);
                         $campData = [];
                         foreach ([1 => 'DS', 2 => 'FS'] as $index => $item) {
                             $campData[$item] = implode(",", array_unique(array_flatten(array_filter(array_map(function ($camp) use($index) {
                                 if ($camp->campaign_type == $index) {
                                     return array_unique(array_merge(array_keys(json_decode($camp->for_category_ids, true)), array_flatten(json_decode($camp->for_category_ids, true))));
                                 } else {
                                     return null;
                                 }
                             }, $campaignDetails)))));
                         }
                         foreach ([1 => 'DS', 2 => 'FS'] as $index => $item) {
                             $campDatasForCampaignName[$item] = implode(",", array_unique(array_flatten(array_filter(array_map(function ($campDatasForCampaignName) use($index) {
                                 if ($campDatasForCampaignName->campaign_type == $index) {
                                     //                                        return array_unique(array_merge(array_keys(json_decode($camp->for_category_ids, true)), array_flatten(json_decode($camp->for_category_ids, true))));
                                     return $campDatasForCampaignName->campaign_banner;
                                 } else {
                                     return null;
                                 }
                             }, $campaignDetails)))));
                         }
                         $where = ['rawQuery' => 'category_status = ? AND category_id IN(' . implode(',', array_unique(explode(',', implode(',', $campData)))) . ')', 'bindParams' => [1]];
                         $selectColumn = ['product_categories.*'];
                         $categoryInfo = $objCategoryModel->getCategoryWhere($where, $selectColumn);
                         $final['categoryInfo'] = $categoryInfo;
                         $final['campaignCatId'] = $campData;
                         $final['campName'] = $campDatasForCampaignName;
                         //                            echo'<pre>';print_r($final);die("fgvj");
                         if ($final) {
                             $response->code = 200;
                             $response->message = "Success";
                             $response->data = $final;
                         } else {
                             $response->code = 100;
                             $response->message = "Something went Wrong. No Product Details found.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
         }
     }
 }
 public function shopDetails(Request $request)
 {
     $postData = $request->all();
     $response = new stdClass();
     $objUserModel = new User();
     if ($postData) {
         $userId = '';
         if (isset($postData['id'])) {
             $userId = $postData['id'];
         }
         $mytoken = '';
         $authflag = false;
         if (isset($postData['mytoken'])) {
             $mytoken = $postData['mytoken'];
             if ($mytoken == env("API_TOKEN")) {
                 $authflag = true;
             } else {
                 if ($userId != '') {
                     $whereForloginToken = $userId;
                     DB::setFetchMode(PDO::FETCH_ASSOC);
                     $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                     if ($mytoken == $Userscredentials['login_token']) {
                         $authflag = true;
                     }
                 }
             }
         }
         if ($authflag) {
             //LOGIN TOKEN
             $count = 10;
             // The number of rows to return.    //THIS FIELD IS STATIC AS OF NOW
             if (isset($postData['count'])) {
                 $count = $postData['count'];
             }
             $offset = '';
             //Start returning after this many rows.
             if (isset($postData['offset'])) {
                 $offset = $postData['offset'];
             }
             $objShopsModel = new Shops();
             $shopDetails = $objShopsModel->getShopDetail($count, $offset);
             //Get all shops list and pagination for all shops
             if ($shopDetails) {
                 $data = $shopDetails;
                 $response->code = 200;
                 $response->message = "Success";
                 $response->data = $data;
             } else {
                 $response->code = 100;
                 $response->message = "Something went Wrong. No Product Details found.";
                 $response->data = null;
             }
         } else {
             $response->code = 401;
             $response->message = "Access Denied";
             $response->data = null;
         }
     } else {
         $response->code = 401;
         $response->message = "Invalid request";
         $response->data = null;
     }
     echo json_encode($response, true);
 }
 /**
  * @param Request $request
  */
 public function productAjaxHandler(Request $request)
 {
     $method = $request->input('method');
     $response = new stdClass();
     if ($method != "") {
         switch ($method) {
             case 'productsizingdetails':
                 $postData = $request->all();
                 if ($postData) {
                     $objProductmetaModel = new Productmeta();
                     $objUserModel = new User();
                     $userId = '';
                     if (isset($postData['id'])) {
                         $userId = $postData['id'];
                     }
                     $whereForloginToken = $userId;
                     $productmetaId = '';
                     if (isset($postData['productmeta_id'])) {
                         $productmetaId = $postData['productmeta_id'];
                     }
                     $mytoken = 0;
                     $authflag = false;
                     if (isset($postData['mytoken'])) {
                         $mytoken = $postData['mytoken'];
                         if ($mytoken == env("API_TOKEN")) {
                             $authflag = true;
                         } else {
                             if ($userId != '') {
                                 DB::setFetchMode(PDO::FETCH_ASSOC);
                                 $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                                 if ($mytoken == $Userscredentials['login_token']) {
                                     $authflag = true;
                                 }
                             }
                         }
                     }
                     if ($authflag) {
                         if ($productmetaId != '') {
                             DB::setFetchMode(PDO::FETCH_ASSOC);
                             $productsizeDetails = $objProductmetaModel->getProductsizeDetails($productmetaId);
                             $data = array();
                             foreach ($productsizeDetails as $sizekey => $sizeval) {
                                 $presentTime = time();
                                 $sizeval['discountFlag'] = 0;
                                 if ($sizeval['discount_value'] > 0) {
                                     $disountFlag = TRUE;
                                     if ($sizeval['available_from'] != '' || $sizeval['available_upto'] != '') {
                                         if ($sizeval['available_from'] != '' && $sizeval['available_from'] > $presentTime) {
                                             $disountFlag = FALSE;
                                         }
                                         if ($sizeval['available_upto'] != '' && $sizeval['available_upto'] < $presentTime) {
                                             $disountFlag = FALSE;
                                         }
                                     }
                                     if ($disountFlag) {
                                         $discountedValue = 0;
                                         $productPrice = (int) $sizeval['price'];
                                         if ($sizeval['discount_type'] == 1) {
                                             $discountedValue = $productPrice - (int) $sizeval['discount_value'];
                                         }
                                         if ($sizeval['discount_type'] == 2) {
                                             $discountedValue = $productPrice - (int) ($productPrice * ((int) $sizeval['discount_value'] / 100));
                                         }
                                         $data[$sizekey] = $sizeval;
                                         //['productsizeDetails']
                                         $data[$sizekey]['discountedprice'] = $discountedValue;
                                         $data[$sizekey]['discountFlag'] = 1;
                                     }
                                 }
                             }
                             $response->code = 200;
                             $response->message = "Success";
                             $response->data = $data;
                         } else {
                             $response->code = 100;
                             $response->message = "Something went Wrong. No Product Details found.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 100;
                     $response->message = "Something went Wrong. No Details for Post.";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             case 'getCategoryForMenu':
                 $ObjProductCategoryModel = new ProductCategories();
                 $objuser = new User();
                 $API_TOKEN = env('API_TOKEN');
                 if ($request->isMethod("POST")) {
                     $postData = $request->all();
                     if (isset($postData['api_token'])) {
                         $apitoken = $postData['api_token'];
                     }
                     if ($apitoken == $API_TOKEN) {
                         $ObjProductCategoryModel = ProductCategories::getInstance();
                         $where = ['rawQuery' => 'category_status = ? AND is_visible = ?', 'bindParams' => [1, 'Y']];
                         $selectColumn = ['product_categories.*', DB::raw('GROUP_CONCAT(product_categories.category_id)AS category_ids'), DB::raw('GROUP_CONCAT(product_categories.category_name)AS category_names')];
                         //                            $cacheKey = "product_categories::" . implode('-', array_flatten($where));
                         //                            if (cacheGet($cacheKey)) {
                         //                                $categoryInfo = cacheGet($cacheKey);
                         //                            } else {
                         $categoryInfo = $ObjProductCategoryModel->getAllCategories($where, $selectColumn);
                         //echo'                        <pre>';print_r($categoryInfo);die("sdfv");
                         //                            $com = array();
                         //                            foreach($categoryInfo as $key => $val){
                         //                                 if($val->parent_category_id != 0 && $val->category_id) {
                         //                                     $com[$key] = $val->category_name;
                         //                                 }
                         //                            }
                         //    echo'<pre>';print_r($com);die("dxg");
                         //                                cacheForever($cacheKey, $categoryInfo);
                         //                            }
                         if ($categoryInfo) {
                             $response->code = 200;
                             $response->message = "Success";
                             $response->data = $categoryInfo;
                         } else {
                             $response->code = 400;
                             $response->message = "No user Details found.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             default:
                 break;
         }
     }
 }
 public function productAjaxHandler(Request $request)
 {
     $method = $request->input('method');
     if ($method != "") {
         switch ($method) {
             case 'productsizingdetails':
                 $postData = $request->all();
                 $response = new stdClass();
                 if ($postData) {
                     $objProductmetaModel = new Productmeta();
                     $objUserModel = new User();
                     $userId = '';
                     if (isset($postData['id'])) {
                         $userId = $postData['id'];
                     }
                     $whereForloginToken = $userId;
                     $productmetaId = '';
                     if (isset($postData['productmeta_id'])) {
                         $productmetaId = $postData['productmeta_id'];
                     }
                     $mytoken = 0;
                     $authflag = false;
                     if (isset($postData['mytoken'])) {
                         $mytoken = $postData['mytoken'];
                         if ($mytoken == env("API_TOKEN")) {
                             $authflag = true;
                         } else {
                             if ($userId != '') {
                                 DB::setFetchMode(PDO::FETCH_ASSOC);
                                 $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                                 if ($mytoken == $Userscredentials['login_token']) {
                                     $authflag = true;
                                 }
                             }
                         }
                     }
                     if ($authflag) {
                         if ($productmetaId != '') {
                             DB::setFetchMode(PDO::FETCH_ASSOC);
                             $productsizeDetails = $objProductmetaModel->getProductsizeDetails($productmetaId);
                             $data = array();
                             foreach ($productsizeDetails as $sizekey => $sizeval) {
                                 $presentTime = time();
                                 $sizeval['discountFlag'] = 0;
                                 if ($sizeval['discount_value'] > 0) {
                                     $disountFlag = TRUE;
                                     if ($sizeval['available_from'] != '' || $sizeval['available_upto'] != '') {
                                         if ($sizeval['available_from'] != '' && $sizeval['available_from'] > $presentTime) {
                                             $disountFlag = FALSE;
                                         }
                                         if ($sizeval['available_upto'] != '' && $sizeval['available_upto'] < $presentTime) {
                                             $disountFlag = FALSE;
                                         }
                                     }
                                     if ($disountFlag) {
                                         $discountedValue = 0;
                                         $productPrice = (int) $sizeval['price'];
                                         if ($sizeval['discount_type'] == 1) {
                                             $discountedValue = $productPrice - (int) $sizeval['discount_value'];
                                         }
                                         if ($sizeval['discount_type'] == 2) {
                                             $discountedValue = $productPrice - (int) ($productPrice * ((int) $sizeval['discount_value'] / 100));
                                         }
                                         $data[$sizekey] = $sizeval;
                                         //['productsizeDetails']
                                         $data[$sizekey]['discountedprice'] = $discountedValue;
                                         $data[$sizekey]['discountFlag'] = 1;
                                     }
                                 }
                             }
                             $response->code = 200;
                             $response->message = "Success";
                             $response->data = $data;
                         } else {
                             $response->code = 100;
                             $response->message = "Something went Wrong. No Product Details found.";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 100;
                     $response->message = "Something went Wrong. No Details for Post.";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             default:
                 break;
         }
     }
 }
 /**
  *  This service is use to handle profile it has 4 methods changegeneralinfo, changeshippinginfo, changepassword and changeavtar
  * @param changegeneralinfo : method, user_id, firstname, lastname, contact_no, api_token, secondary_email
  * @return $updategeneralinfo
  * @param changeshippinginfo : method, user_id,  mytoken, city, state, zipcode, api_token, address_line_1, address_line_2
  * @return $updateshippinginfo
  * @param changepassword : method, user_id, oldPassword, newPassword, reNewPassword, api_token
  * @return $Updatepassword
  * @param changeavtar : method, user_id, api_token, input_file_preview
  * @return $url
  */
 public function profileAjaxHandler(Request $request)
 {
     $response = new stdClass();
     if ($request->isMethod("POST")) {
         $postData = $request->all();
         $API_TOKEN = env('API_TOKEN');
         $method = "";
         if (isset($postData['method'])) {
             $method = $postData['method'];
         }
         $objuser = new User();
         $objusermetamodel = new Usersmeta();
         switch ($method) {
             case "changegeneralinfo":
                 $userId = "";
                 if (isset($postData['user_id'])) {
                     $userId = $postData['user_id'];
                 }
                 $firstname = "";
                 if (isset($postData['firstname'])) {
                     $firstname = $postData['firstname'];
                 }
                 $lastname = "";
                 if (isset($postData['lastname'])) {
                     $lastname = $postData['lastname'];
                 }
                 $contact_no = "";
                 if (isset($postData['contact_no'])) {
                     $contact_no = $postData['contact_no'];
                 }
                 $email = "";
                 if (isset($postData['email'])) {
                     $email = $postData['email'];
                 }
                 $username = "";
                 if (isset($postData['username'])) {
                     $username = $postData['username'];
                 }
                 $authFlag = false;
                 if (isset($postData['api_token'])) {
                     $apitoken = $postData['api_token'];
                     if ($apitoken == $API_TOKEN) {
                         $authFlag = true;
                     } else {
                         if ($userId != '') {
                             $whereForUpdate = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                             $Userscredentials = $objuser->getUsercredsWhere($whereForUpdate);
                             if ($apitoken == $Userscredentials->login_token) {
                                 $authFlag = true;
                             }
                         }
                     }
                 }
                 if ($authFlag) {
                     $rules = array('firstname' => 'required|regex:/^[A-Za-z\\s]+$/|max:255', 'lastname' => 'required|regex:/^[A-Za-z\\s]+$/|max:255', 'username' => 'required|regex:/^[A-Za-z0-9._\\s]+$/|max:255', 'email' => 'required|email|max:255', 'user_id' => 'required');
                     $messages = ['firstname.regex' => 'The :attribute cannot contain special characters.', 'lastname.regex' => 'The :attribute cannot contain special characters.', 'username.regex' => 'The :attribute cannot contain special characters.'];
                     $validator = Validator::make($request->all(), $rules, $messages);
                     if ($validator->fails()) {
                         $response->code = 100;
                         $response->message = $validator->messages();
                         $response->data = null;
                         echo json_encode($response, true);
                     } else {
                         $whereForUpdate = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                         $currentUserDetails = $objuser->getUsercredsWhere($whereForUpdate);
                         $uniqueflag = false;
                         if ($currentUserDetails->username == $username && $currentUserDetails->username == $email) {
                             $uniqueflag = true;
                         } else {
                             if ($currentUserDetails->username != $username && $currentUserDetails->username == $email) {
                                 $uniqueflag = true;
                             } else {
                                 if ($currentUserDetails->username == $username && $currentUserDetails->username != $email) {
                                     $uniqueflag = true;
                                 } else {
                                     $rules = array('username' => 'unique:users', 'email' => 'unique:users');
                                     $validator = Validator::make($request->all(), $rules);
                                     if ($validator->fails()) {
                                         $response->code = 100;
                                         $response->message = $validator->messages();
                                         $response->data = null;
                                         echo json_encode($response, true);
                                     } else {
                                         $uniqueflag = true;
                                     }
                                 }
                             }
                         }
                         if ($uniqueflag) {
                             $whereForId = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                             $data = array('name' => $firstname, 'last_name' => $lastname, 'username' => $username, 'email' => $email);
                             $updategeneralinfo = $objuser->UpdateUserDetailsbyId($whereForId, $data);
                             $whereForUserId = ['rawQuery' => 'user_id =?', 'bindParams' => [$userId]];
                             $Isuseravailable = $objusermetamodel->getUsermetaWhere($whereForUserId);
                             if ($Isuseravailable) {
                                 $dataupdate = array('phone' => "{$contact_no}");
                                 $UpdateUsermeta = $objusermetamodel->UpdateUsermetawhere($whereForUserId, $dataupdate);
                             } else {
                                 $dataadd = array('user_id' => $userId, 'phone' => $contact_no);
                                 $Addusermeta = $objusermetamodel->addUsermeta($dataadd);
                             }
                             if ($updategeneralinfo) {
                                 $response->code = 200;
                                 $response->message = "Update Successful";
                                 $response->data = $updategeneralinfo;
                                 echo json_encode($response, true);
                             } else {
                                 $response->code = 400;
                                 $response->message = "Something went wrong";
                                 $response->data = 1;
                                 echo json_encode($response, true);
                             }
                         }
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Access Denied";
                     $response->data = null;
                     echo json_encode($response, true);
                 }
                 break;
             case "changeshippinginfo":
                 $userId = "";
                 if (isset($postData['user_id'])) {
                     $userId = $postData['user_id'];
                 }
                 $City = "";
                 if (isset($postData['city'])) {
                     $City = $postData['city'];
                 }
                 $State = "";
                 if (isset($postData['state'])) {
                     $State = $postData['state'];
                 }
                 $Zip_code = "";
                 if (isset($postData['zipcode'])) {
                     $Zip_code = $postData['zipcode'];
                 }
                 //                    $country = "";
                 //                    if (isset($postData['country'])) {
                 //                        $country = $postData['country'];
                 //                    }
                 $Address1 = "";
                 if (isset($postData['address_line_1'])) {
                     $Address1 = $postData['address_line_1'];
                 }
                 $Address2 = "";
                 if (isset($postData['address_line_2'])) {
                     $Address2 = $postData['address_line_2'];
                 }
                 $authFlag = false;
                 if (isset($postData['api_token'])) {
                     $apitoken = $postData['api_token'];
                     if ($apitoken == $API_TOKEN) {
                         $authFlag = true;
                     } else {
                         if ($userId != '') {
                             $whereForUpdate = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                             $Userscredentials = $objuser->getUsercredsWhere($whereForUpdate);
                             if ($apitoken == $Userscredentials->login_token) {
                                 $authFlag = true;
                             }
                         }
                     }
                 }
                 if ($authFlag) {
                     $rules = array('city' => 'required', 'state' => 'required', 'zipcode' => 'required', 'address_line_1' => 'required');
                     $validator = Validator::make($request->all(), $rules);
                     if ($validator->fails()) {
                         $response->code = 100;
                         $response->message = $validator->messages();
                         $response->data = null;
                         echo json_encode($response);
                     } else {
                         $whereForUserId = ['rawQuery' => 'user_id =?', 'bindParams' => [$userId]];
                         $Isuseravailable = $objusermetamodel->getUsermetaWhere($whereForUserId);
                         if ($Isuseravailable) {
                             $data = array('city' => $City, 'state' => $State, 'zipcode' => $Zip_code, 'addressline1' => $Address1, 'addressline2' => $Address2);
                             $updateshippinginfo = $objusermetamodel->UpdateUsermetawhere($whereForUserId, $data);
                         } else {
                             $dataadd = array('user_id' => $userId, 'city' => $City, 'state' => $State, 'zipcode' => $Zip_code, 'addressline1' => $Address1, 'addressline2' => $Address2);
                             $Addusermeta = $objusermetamodel->addUsermeta($dataadd);
                         }
                         if ($updateshippinginfo || $Addusermeta) {
                             $response->code = 200;
                             $response->message = "Update Successful";
                             $response->data = 1;
                             echo json_encode($response, true);
                         } else {
                             $response->code = 400;
                             $response->message = "Something went Wrong";
                             $response->data = null;
                             echo json_encode($response, true);
                         }
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Access Denied";
                     $response->data = null;
                     echo json_encode($response, true);
                 }
                 break;
             case "changepassword":
                 $userId = "";
                 if (isset($postData['user_id'])) {
                     $userId = $postData['user_id'];
                 }
                 $oldpassword = "";
                 if (isset($postData['oldPassword'])) {
                     $oldpassword = $postData['oldPassword'];
                 }
                 $newpassword = "";
                 if (isset($postData['newPassword'])) {
                     $newpassword = $postData['newPassword'];
                 }
                 $renewpassword = "";
                 if (isset($postData['reNewPassword'])) {
                     $renewpassword = $postData['reNewPassword'];
                 }
                 $authFlag = false;
                 if (isset($postData['api_token'])) {
                     $apitoken = $postData['api_token'];
                     if ($apitoken == $API_TOKEN) {
                         $authFlag = true;
                     } else {
                         if ($userId != '') {
                             $whereForUpdate = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                             $Userscredentials = $objuser->getUsercredsWhere($whereForUpdate);
                             if ($apitoken == $Userscredentials->login_token) {
                                 $authFlag = true;
                             }
                         }
                     }
                 }
                 if ($authFlag) {
                     $rules = array('oldPassword' => 'required', 'newPassword' => 'required', 'reNewPassword' => 'required', 'user_id' => 'required');
                     $validator = Validator::make($request->all(), $rules);
                     if ($validator->fails()) {
                         $response->code = 100;
                         $response->message = $validator->messages();
                         $response->data = null;
                         echo json_encode($response);
                     } else {
                         if ($newpassword != $oldpassword) {
                             if ($newpassword == $renewpassword) {
                                 $where = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                                 $currentUserDetails = $objuser->getUsercredsWhere($where);
                                 if (Hash::check($oldpassword, $currentUserDetails->password)) {
                                     $newpassword = Hash::make($newpassword);
                                     $data = array('password' => $newpassword);
                                     $Updatepassword = $objuser->UpdateUserDetailsbyId($where, $data);
                                     $response->code = 200;
                                     $response->message = "Password Changed Successfully";
                                     $response->data = 1;
                                     echo json_encode($response, true);
                                 } else {
                                     $response->code = 400;
                                     $response->message = "Invalid Password";
                                     $response->data = null;
                                     echo json_encode($response, true);
                                 }
                             } else {
                                 $response->code = 400;
                                 $response->message = "Both New password should be same";
                                 $response->data = null;
                                 echo json_encode($response, true);
                             }
                         } else {
                             $response->code = 400;
                             $response->message = "New and old password should not be same";
                             $response->data = null;
                             echo json_encode($response, true);
                         }
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Access Denied";
                     $response->data = null;
                     echo json_encode($response, true);
                 }
                 break;
             case "changeavtar":
                 //This method is directly called from Ajax call of profile-setting.blade.php page
                 $userId = "";
                 if (isset($postData['user_id'])) {
                     $userId = $postData['user_id'];
                 }
                 $authFlag = false;
                 if (isset($postData['api_token'])) {
                     $apitoken = $postData['api_token'];
                     if ($apitoken == $API_TOKEN) {
                         $authFlag = true;
                     } else {
                         if ($userId != '') {
                             $whereForUpdate = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                             $Userscredentials = $objuser->getUsercredsWhere($whereForUpdate);
                             if ($apitoken == $Userscredentials->login_token) {
                                 $authFlag = true;
                             }
                         }
                     }
                 }
                 if ($authFlag) {
                     if ($userId != '') {
                         if (Input::hasFile('file')) {
                             $validator = Validator::make($request->all(), ['file' => 'image']);
                             if ($validator->fails()) {
                                 $response->code = 100;
                                 $response->message = $validator->messages();
                                 $response->data = null;
                                 echo json_encode($response);
                             } else {
                                 $destinationPath = $_SERVER['DOCUMENT_ROOT'] . '/../../web/public/assets/uploads/useravatar/';
                                 $filename = $userId . '_' . time() . ".jpg";
                                 File::makeDirectory($destinationPath, 0777, true, true);
                                 $filePath = $destinationPath . $filename;
                                 $quality = $this->imageQuality(Input::file('file'));
                                 Image::make(Input::file('file'))->resize(1024, 1024, function ($constraint) {
                                     $constraint->aspectRatio();
                                 })->save($filePath, $quality);
                                 $filepathupdate = '/assets/uploads/useravatar/' . $filename;
                                 $updateData['profilepic'] = $filepathupdate;
                                 $where = ['rawQuery' => 'id =?', 'bindParams' => [$userId]];
                                 $UserData = $objuser->getUsercredsWhere($where);
                                 $updatedResult = $objuser->UpdateUserDetailsbyId($where, $updateData);
                                 if ($updatedResult) {
                                     if ($UserData->profilepic != '') {
                                         File::delete(public_path() . '/../../web/public' . $UserData->profilepic);
                                     }
                                     $response->code = 200;
                                     $response->message = "Successfully updated profile image.";
                                     $response->data = $filepathupdate;
                                     echo json_encode($response);
                                 } else {
                                     $response->code = 400;
                                     $response->message = "Something went wrong, please try again.";
                                     $response->data = null;
                                     echo json_encode($response);
                                 }
                             }
                         } else {
                             $response->code = 400;
                             $response->message = "Give correct input and Input Image files should be(jpg,gif,png,jpeg)only";
                             $response->data = null;
                             echo json_encode($response, true);
                         }
                     } else {
                         $response->code = 400;
                         $response->message = "You need to login to change Avtar.";
                         $response->data = null;
                         echo json_encode($response, true);
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Access Denied";
                     $response->data = null;
                     echo json_encode($response, true);
                 }
                 break;
             default:
                 break;
         }
     } else {
         $response->code = 401;
         $response->message = "Invalid request";
         $response->data = null;
         echo json_encode($response, true);
     }
 }
 /**
  *  This service is use for Forgot Password has 3 methods EnterEmailId, verifyResetCode and resetPassword
  * @param api_token, fpwemail, resetcode, method, password, re_password
  * @return int
  */
 public function forgotPassword(Request $request)
 {
     $response = new stdClass();
     if ($request->isMethod("POST")) {
         $postData = $request->all();
         $API_TOKEN = env('API_TOKEN');
         $apitoken = "";
         if (isset($postData['api_token'])) {
             $apitoken = $postData['api_token'];
         }
         $method = "";
         if (isset($postData['method'])) {
             $method = $postData['method'];
         }
         $objUsersModel = new User();
         switch ($method) {
             case "EnterEmailId":
                 if ($request->isMethod("POST")) {
                     $fpwemail = '';
                     if (isset($postData['fpwemail'])) {
                         $fpwemail = $postData['fpwemail'];
                     }
                     if ($apitoken == $API_TOKEN) {
                         if ($fpwemail != '') {
                             $resetcode = mt_rand(100000, 999999);
                             $exists = $objUsersModel->checkMail($fpwemail, $resetcode);
                             if ($exists) {
                                 $objMailTemplate = new MailTemplate();
                                 $temp_name = "Enter_mail_fp";
                                 $mailTempContent = $objMailTemplate->getTemplateByName($temp_name);
                                 $key = env('MANDRILL_KEY');
                                 $mandrill = new Mandrill($key);
                                 $async = false;
                                 $ip_pool = 'Main Pool';
                                 $message = array('html' => $mailTempContent->temp_content, 'subject' => "Reset Code", 'from_email' => "*****@*****.**", 'to' => array(array('email' => $postData['fpwemail'], 'type' => 'to')), 'merge_vars' => array(array("rcpt" => $postData['fpwemail'], 'vars' => array(array("name" => "usermail", "content" => $postData['fpwemail']), array('name' => 'resetcode', 'content' => $resetcode)))));
                                 $mailrespons = $mandrill->messages->send($message, $async, $ip_pool);
                                 if ($mailrespons[0]['status'] == "sent") {
                                     $response->code = 200;
                                     $response->message = "Mail Sent with Reset code";
                                     $response->data = 1;
                                 }
                             } else {
                                 $response->code = 400;
                                 $response->message = "Email Doesnt Exist. Enter correct Email.";
                                 $response->data = null;
                             }
                         } else {
                             $response->code = 400;
                             $response->message = "You missed something";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             case "verifyResetCode":
                 if ($request->isMethod("POST")) {
                     $fpwemail = '';
                     if (isset($postData['fpwemail'])) {
                         $fpwemail = $postData['fpwemail'];
                     }
                     $resetcode = '';
                     if (isset($postData['resetcode'])) {
                         $resetcode = $postData['resetcode'];
                     }
                     if ($apitoken == $API_TOKEN) {
                         if ($fpwemail != '' && $resetcode != '') {
                             $whereForUpdate = ['rawQuery' => 'email = ? and reset_code = ?', 'bindParams' => [$fpwemail, $resetcode]];
                             $exists = $objUsersModel->verifyResetCode($whereForUpdate);
                             if ($exists) {
                                 $response->code = 200;
                                 $response->message = "Reset Code Verified Successfully.";
                                 $response->data = $exists;
                             } else {
                                 $response->code = 400;
                                 $response->message = "Reset Code Didnt Matched, Enter Correct Reset Code.";
                                 $response->data = null;
                             }
                         } else {
                             $response->code = 400;
                             $response->message = "You missed something";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             case "resetPassword":
                 if ($request->isMethod("POST")) {
                     $fpwemail = '';
                     if (isset($postData['fpwemail'])) {
                         $fpwemail = $postData['fpwemail'];
                     }
                     $resetcode = '';
                     if (isset($postData['resetcode'])) {
                         $resetcode = $postData['resetcode'];
                     }
                     $password = '';
                     if (isset($postData['password'])) {
                         $password = $postData['password'];
                     }
                     $re_password = '';
                     if (isset($postData['re_password'])) {
                         $re_password = $postData['re_password'];
                     }
                     if ($apitoken == $API_TOKEN) {
                         if ($fpwemail != '' && $resetcode != '' && $password != '' && $re_password != '') {
                             if ($password == $re_password) {
                                 $exists = $objUsersModel->resetPassword($fpwemail, $resetcode, Hash::make($password));
                                 if ($exists) {
                                     $response->code = 200;
                                     $response->message = "Password Changed Successfully.";
                                     $response->data = $exists;
                                 } else {
                                     $response->code = 400;
                                     $response->message = "Something went Wrong. Provide Correct Input.";
                                     $response->data = null;
                                 }
                             } else {
                                 $response->code = 400;
                                 $response->message = "Password Didnt match";
                                 $response->data = null;
                             }
                         } else {
                             $response->code = 400;
                             $response->message = "You missed something";
                             $response->data = null;
                         }
                     } else {
                         $response->code = 401;
                         $response->message = "Access Denied";
                         $response->data = null;
                     }
                 } else {
                     $response->code = 401;
                     $response->message = "Invalid request";
                     $response->data = null;
                 }
                 echo json_encode($response, true);
                 break;
             default:
                 break;
         }
     }
 }
 /**
  * Get all the products based on filtering and category selection.
  * Gets product listing
  * Category,Subcategory,Filters & Feature Variant name,Sort By.
  * @param Request $request
  * @author: Vini Dubey<*****@*****.**>
  * @since: 05/05/2016
  */
 public function productList(Request $request)
 {
     $postData = $request->all();
     $response = new stdClass();
     $objUserModel = new User();
     if ($postData) {
         $userId = '';
         if (isset($postData['id'])) {
             $userId = $postData['id'];
         }
         $mytoken = '';
         $authflag = false;
         if (isset($postData['api_token'])) {
             $mytoken = $postData['api_token'];
             if ($mytoken == env("API_TOKEN")) {
                 $authflag = true;
             } else {
                 if ($userId != '') {
                     $whereForloginToken = $userId;
                     $Userscredentials = $objUserModel->getUsercredsWhere($whereForloginToken);
                     if ($mytoken == $Userscredentials['login_token']) {
                         $authflag = true;
                     }
                 }
             }
         }
         if ($authflag) {
             //LOGIN TOKEN
             //                if (isset($postData['option']) && isset($postData['limit']) && isset($postData['page_number'])) {
             if (isset($postData['option']) && isset($postData['limit']) && isset($postData['page_number'])) {
                 $objProductModel = Products::getInstance();
                 $objProductCategoryModel = ProductCategories::getInstance();
                 $wherePriceRange = ['rawQuery' => 1];
                 if (isset($postData['price_range_from']) && !empty($postData['price_range_from']) && isset($postData['price_range_upto']) && !empty($postData['price_range_upto'])) {
                     $priceFrom = $postData['price_range_from'];
                     $priceTo = $postData['price_range_upto'];
                     $wherePriceRange = ['rawQuery' => 'price_total >= ' . $priceFrom . ' AND price_total <= ' . $priceTo . ''];
                 }
                 //                    $sortClause = "products.product_id DESC";
                 //                    $sortClause = ('products.product_id desc');
                 $sortClause = ['products.product_id' => 'desc'];
                 if (isset($postData['sort_by']) && !empty($postData['sort_by'])) {
                     $sortBy = $postData['sort_by'];
                     switch ($sortBy) {
                         case "null-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'asc'];
                             break;
                         case "timestamp-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'asc'];
                             break;
                         case "position-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'asc'];
                             break;
                         case "position-desc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'asc'];
                             break;
                         case "price-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.price_total' => 'asc'];
                             break;
                         case "price-desc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.price_total' => 'desc'];
                             break;
                         case "popularity-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.price_total' => 'asc'];
                             break;
                         case "bestsellers-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'asc'];
                             break;
                         case "bestsellers-desc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'desc'];
                             break;
                         case "on_sale-asc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'asc'];
                             break;
                         case "on_sale-desc":
                             //                                $sortClause = ('products.product_id desc');
                             $sortClause = ['products.product_id' => 'desc'];
                             break;
                         case "pricelowtohigh":
                             //                                $sortClause = ('products.price_total asc');
                             $sortClause = ['products.price_total' => 'asc'];
                             break;
                         case "pricehightolow":
                             //                                $sortClause = ('products.price_total desc');
                             $sortClause = ['products.price_total' => 'desc'];
                             break;
                         default:
                             break;
                     }
                 }
                 $limit = $postData['limit'];
                 $pagenumber = $postData['page_number'];
                 if (empty($postData['page_number'])) {
                     $pagenumber = 1;
                 }
                 $categoryName = '';
                 $subcategoryName = '';
                 $whereForCategoryFilter = ['rawQuery' => 1];
                 $objProductModel = Products::getInstance();
                 if (isset($postData['category_name']) && !empty($postData['category_name'])) {
                     $categoryName = $postData['category_name'];
                     if (isset($postData['subcategory_name']) && !empty($postData['subcategory_name'])) {
                         $subcategoryName = $postData['subcategory_name'];
                     }
                     $objCategoryModel = ProductCategories::getInstance();
                     $whereCategoryName = ['rawQuery' => 'category_name = ? AND parent_category_id = ? AND category_status = ?', 'bindParams' => [$categoryName, 0, 1]];
                     $selectedColumn = ['product_categories.*'];
                     $categoryDetails = $objCategoryModel->getCategoryWhere($whereCategoryName, $selectedColumn);
                     if ($categoryDetails) {
                         $categoryTreeIds = $categoryDetails[0]->category_id;
                         $whereForCategoryFilter = ['rawQuery' => 'category_id IN(' . $categoryTreeIds . ')'];
                         $whereForSubcat = ['rawQuery' => 'parent_category_id = ? AND category_status = ?', 'bindParams' => [$categoryDetails[0]->category_id, 1]];
                         $selectedColumn = ['product_categories.*', DB::raw('GROUP_CONCAT(DISTINCT category_id)AS subcatIds')];
                         $allSubcatsInCat = $objCategoryModel->getAllCategoryWhereByGrouping($whereForSubcat, $selectedColumn);
                         if (!empty($allSubcatsInCat)) {
                             $allSubcatsInCatIds = '';
                             $count = 1;
                             foreach ($allSubcatsInCat as $valueAllSubcatsInCat) {
                                 if ($count == 1) {
                                     $allSubcatsInCatIds = $valueAllSubcatsInCat->subcatIds;
                                 } else {
                                     $allSubcatsInCatIds .= "," . $valueAllSubcatsInCat->subcatIds;
                                 }
                                 $count++;
                             }
                             $categoryTreeIds .= "," . $allSubcatsInCatIds;
                             if ($subcategoryName != '') {
                                 $whereForSelectedSubcat = ['rawQuery' => 'category_name = ? AND parent_category_id = ?', 'bindParams' => [$subcategoryName, $categoryDetails[0]->category_id]];
                                 $selectedColumn = ['product_categories.*'];
                                 $selectedSubcatDetails = $objCategoryModel->getCategoryWhere($whereForSelectedSubcat, $selectedColumn);
                                 if ($selectedSubcatDetails) {
                                     $allSubcatsInCatIds = $selectedSubcatDetails[0]->category_id;
                                     $categoryTreeIds = $allSubcatsInCatIds;
                                 }
                             }
                             $whereForCategoryFilter = ['rawQuery' => 'category_id IN(' . $categoryTreeIds . ')'];
                             $selectedColumn = ['product_categories.*', DB::raw('GROUP_CONCAT(DISTINCT category_id)AS subcatIds')];
                             $allSubsubcatsInCat = $objCategoryModel->getAllCategoryWhereByGrouping($whereForCategoryFilter, $selectedColumn);
                             if (!empty($allSubsubcatsInCat)) {
                                 foreach ($allSubsubcatsInCat as $valueAllSubsubcatsInCat) {
                                     $categoryTreeIds .= "," . $valueAllSubsubcatsInCat->subcatIds;
                                 }
                             }
                         }
                     }
                     // For Filter Option and features //
                     $ObjProductFilterOptionModel = ProductFilterOption::getInstance();
                     //                        $where = ['rawQuery' => 'product_filter_option_status = ? AND product_filter_categories REGEXP "^[[:<:]]' . implode("|", array_unique(explode(",", $categoryTreeIds))) . '[[:<:]]"', 'bindParams' => [1]];
                     $where = ['rawQuery' => 'product_filter_option.product_filter_option_status = ? AND product_filter_option.product_filter_category_id REGEXP  "^' . implode("|", array_unique(explode(",", $categoryTreeIds))) . '"', 'bindParams' => [1]];
                     $selectColumn = ['product_filter_option.*', DB::raw('GROUP_CONCAT(DISTINCT pg.product_filter_option_name)AS variant_name'), DB::raw('GROUP_CONCAT(DISTINCT pg.product_filter_option_id)AS variant_ids')];
                     $filterOptionInfo = $ObjProductFilterOptionModel->getAllFilterOption($where, $selectColumn);
                     // End for filter option and feature//
                 }
                 $offset = ((int) $pagenumber - 1) * (int) $limit;
                 $whereOption = ['rawQuery' => 1];
                 if ($postData['option'] != '') {
                     $whereOption = ['rawQuery' => 'product_option_variants.variant_id IN (' . $postData["option"] . ')'];
                     //                                $whereForFilter.= " and pcr.color_id in (" . $postData['selectedcolors'] . ")";
                 }
                 $whereForFilter = $whereOption;
                 $where = ['rawQuery' => 'product_status = ?', 'bindParams' => [1]];
                 $selectedColumn = ['products.*', 'product_images.image_url', 'productmeta.*', DB::raw('GROUP_CONCAT(DISTINCT product_option_variant_relation.option_id)AS option_ids'), DB::raw('GROUP_CONCAT(DISTINCT product_options.option_name)AS option_names'), DB::raw('GROUP_CONCAT(DISTINCT product_option_variant_relation.variant_data  SEPARATOR "____")AS variant_datas'), DB::raw('GROUP_CONCAT(DISTINCT product_option_variants_combination.variant_ids) AS variant_ids_combination')];
                 $productsFiltered = $objProductModel->getProducts($where, $whereForCategoryFilter, $whereForFilter, $limit, $offset, $sortClause, $wherePriceRange, $selectedColumn);
                 $FilterDatas['filterDetails'] = $filterOptionInfo;
                 $FilterDatas['productList'] = $productsFiltered;
                 //                    echo'<pre>';print_r($FilterDatas);die("dv");
                 if ($FilterDatas) {
                     $data = $filterOptionInfo;
                     $response->code = 200;
                     $response->message = "Success";
                     $response->data = $data;
                 } else {
                     $response->code = 100;
                     $response->message = "Something went Wrong. No Product Details found.";
                     $response->data = null;
                 }
             } else {
                 $errorMsg = "No parameters were found.";
                 $response->code = 100;
                 $response->message = $errorMsg;
                 $response->data = null;
             }
         } else {
             $response->code = 401;
             $response->message = "Access Denied";
             $response->data = null;
         }
     } else {
         $response->code = 401;
         $response->message = "Invalid request";
         $response->data = null;
     }
     echo json_encode($response, true);
 }