Exemple #1
0
 /**
  * Reads the details of the LaCarte matching the
  * passed name.
  * 
  * @access	public
  * @param	string	$laCarte
  * @return	array
  * @since	1.0.0
  * @version	1.0.0
  */
 public static function getALaCarteDetails($aLaCarteID)
 {
     if (!is_numeric($aLaCarteID)) {
         $query = DB::table('vendor_locations')->where('slug', $aLaCarteID)->select('id')->first();
         if ($query) {
             $aLaCarteID = $query->id;
         } else {
             $arrData['status'] = Config::get('constants.API_SUCCESS');
             $arrData['no_result_msg'] = 'No matching values found.';
             $arrData['data'] = array();
             $arrData['total_count'] = 0;
             return $arrDatas;
         }
     }
     //Checking the bookmark status of the product
     $data['access_token'] = $_SERVER['HTTP_X_WOW_TOKEN'];
     $userID = UserDevices::getUserDetailsByAccessToken($data['access_token']);
     $bookmark = DB::table('user_bookmarks as ub')->where('user_id', '=', $userID)->where('vendor_location_id', '=', $aLaCarteID)->select('id', 'type')->first();
     //array to store the matching result
     $arrData = array();
     //query to read the details of the A-La-Carte
     $queryResult = DB::table(DB::raw('vendor_locations as vl'))->join('vendors', 'vendors.id', '=', 'vl.vendor_id')->join(DB::raw('vendor_location_attributes_text as vlat'), 'vlat.vendor_location_id', '=', 'vl.id')->join(DB::raw('vendor_attributes as va'), 'va.id', '=', 'vlat.vendor_attribute_id')->leftjoin(DB::raw('vendor_locations_curator_map as vlcm'), 'vlcm.vendor_location_id', '=', 'vl.id')->leftjoin('curators', 'curators.id', '=', 'vlcm.curator_id')->join(DB::raw('vendor_location_address as vla'), 'vla.vendor_location_id', '=', 'vl.id')->join(DB::raw('locations as loc1'), 'loc1.id', '=', 'vla.area_id')->join(DB::raw('locations as loc2'), 'loc2.id', '=', 'vla.city_id')->join(DB::raw('locations as loc3'), 'loc3.id', '=', 'vla.state_id')->join(DB::raw('locations as loc4'), 'loc4.id', '=', 'vla.country_id')->join('locations as loc5', 'loc5.id', '=', 'vl.location_id')->leftJoin(DB::raw('media_resized_new as m2'), 'm2.id', '=', 'curators.media_id')->leftJoin(DB::raw('vendor_location_attributes_integer as vlai'), 'vlai.vendor_location_id', '=', 'vl.id')->leftJoin(DB::raw('vendor_attributes as va2'), 'va2.id', '=', 'vlai.vendor_attribute_id')->where('vl.id', $aLaCarteID)->where('vl.a_la_carte', '=', 1)->where('vl.status', 'Active')->where('va2.alias', 'reward_points_per_reservation')->groupBy('vl.id')->select('vl.id as vl_id', 'vl.vendor_id', 'vla.address', 'vla.pin_code', 'vla.latitude', 'vla.longitude', 'vendors.name as title', DB::raw('MAX(IF(va.alias = "restaurant_info", vlat.attribute_value, "")) AS resturant_info'), DB::raw('MAX(IF(va.alias = "short_description", vlat.attribute_value, "")) AS short_description'), DB::raw('MAX(IF(va.alias = "terms_and_conditions", vlat.attribute_value, "")) AS terms_conditions'), DB::raw('MAX(IF(va.alias = "menu_picks", vlat.attribute_value, "")) AS menu_picks'), DB::raw('MAX(IF(va.alias = "expert_tips", vlat.attribute_value, "")) AS expert_tips'), DB::raw('MAX(IF(va.alias = "special_offer_title", vlat.attribute_value, "")) AS special_offer_title'), DB::raw('MAX(IF(va.alias = "special_offer_desc", vlat.attribute_value, "")) AS special_offer_desc'), 'loc1.name as area', 'loc1.id as area_id', 'loc2.name as city', 'loc3.name as state_name', 'loc4.name as country', 'loc5.name as locality', 'curators.name as curator_name', 'curators.bio as curator_bio', 'curators.designation as designation', 'vl.pricing_level', 'vlai.attribute_value as reward_point', 'm2.file as curator_image', 'vl.location_id as vl_location_id', 'vlcm.curator_tips', 'vla.city_id', 'vl.slug')->first();
     if ($queryResult) {
         //reading the review ratings
         $arrReview = Review::findRatingByVendorLocation(array($queryResult->vl_id));
         //reading vendor-cuisine
         $arrVendorCuisine = Self::getVendorLocationCuisine(array($queryResult->vl_id));
         //reading the similar vendors
         $arrSimilarVendor = Self::getSimilarALaCarte(array('location_id' => $queryResult->area_id, 'pricing_level' => $queryResult->pricing_level, 'city_id' => $queryResult->city_id));
         $arrSimilarAlacarteFilters = $arrSimilarVendor;
         //print_r($filters); die("hmm");
         $arrResultAlacarte = Self::fetchListings($arrSimilarAlacarteFilters);
         //print_r($arrResult); die("hmm");
         //initializing the values for experience
         if (Self::isExperienceAvailable($queryResult->vl_id)) {
             $experienceAvailable = 'true';
             $experienceURL = URL::to('/') . '/experience/' . $aLaCarteID;
         } else {
             $experienceAvailable = 'false';
             $experienceURL = '';
         }
         //getting the images
         $arrImage = self::getVendorImages($queryResult->vl_id);
         //formatting the array for the data
         $arrData['data'] = array('type' => 'A-La-Carte Details', 'id' => $queryResult->vl_id, 'title' => $queryResult->title, 'resturant_information' => empty($queryResult->resturant_info) ? "" : $queryResult->resturant_info, 'short_description' => empty($queryResult->short_description) ? "" : $queryResult->short_description, 'terms_and_condition' => empty($queryResult->terms_conditions) ? "" : $queryResult->terms_conditions, 'special_offer_title' => empty($queryResult->special_offer_title) ? "" : $queryResult->special_offer_title, 'special_offer_desc' => empty($queryResult->special_offer_desc) ? "" : $queryResult->special_offer_desc, 'pricing' => $queryResult->pricing_level, 'image' => $arrImage, 'rating' => array_key_exists($queryResult->vl_id, $arrReview) ? $arrReview[$queryResult->vl_id]['averageRating'] : 0, 'review_count' => array_key_exists($queryResult->vl_id, $arrReview) ? $arrReview[$queryResult->vl_id]['totalRating'] : 0, 'cuisine' => array_key_exists($queryResult->vl_id, $arrVendorCuisine) ? $arrVendorCuisine[$queryResult->vl_id] : array(), 'experience_available' => $experienceAvailable, 'experience_url' => $experienceURL, 'location_address' => array("address_line" => $queryResult->address, "locality" => $queryResult->locality, "area" => $queryResult->area, "city" => $queryResult->city, "pincode" => $queryResult->pin_code, "state" => $queryResult->state_name, "country" => $queryResult->country, "latitude" => $queryResult->latitude, "longitude" => $queryResult->longitude), 'curator_information' => array('curator_name' => is_null($queryResult->curator_name) ? "" : $queryResult->curator_name, 'curator_bio' => is_null($queryResult->curator_bio) ? "" : $queryResult->curator_bio, 'curator_image' => is_null($queryResult->curator_image) ? "" : Config::get('constants.API_MOBILE_IMAGE_URL') . $queryResult->curator_image, 'curator_designation' => is_null($queryResult->designation) ? "" : $queryResult->designation, 'suggestions' => is_null($queryResult->curator_tips) ? "" : $queryResult->curator_tips), 'menu_pick' => is_null($queryResult->menu_picks) ? "" : $queryResult->menu_picks, 'similar_option' => $arrSimilarAlacarteFilters, 'similar_option' => $arrResultAlacarte, 'reward_point' => is_null($queryResult->reward_point) ? 0 : $queryResult->reward_point, 'expert_tips' => is_null($queryResult->expert_tips) ? "" : $queryResult->expert_tips, 'slug' => $queryResult->slug, 'bookmark_status' => is_null($bookmark) ? 0 : 1);
         //reading the review details
         $arrData['data']['review_detail'] = Review::getVendorLocationRatingDetails($queryResult->vl_id);
         //reading the locations
         $arrData['data']['other_location'] = self::getVendorLocation($queryResult->vendor_id, $queryResult->vl_location_id);
         //setting the value of status
         $arrData['status'] = Config::get('constants.API_SUCCESS');
     } else {
         $arrData['status'] = Config::get('constants.API_ERROR');
         $arrData['no_result_msg'] = 'No matching values found.';
     }
     return $arrData;
 }