public function phone_hits($id) { $today = date("Y-m-d H:i:s"); $fiveday = date("Y-m-d H:i:s", strtotime('-30 days')); $tenday = date("Y-m-d H:i:s", strtotime('-60 days')); $fifday = date("Y-m-d H:i:s", strtotime('-90 days')); $twentyday = date("Y-m-d H:i:s", strtotime('-120 days')); $tfiveday = date("Y-m-d H:i:s", strtotime('-150 days')); $thurtyday = date("Y-m-d H:i:s", strtotime('-175 days')); $thurtyfiveday = date("Y-m-d H:i:s", strtotime('-200 days')); //$jsonVariable; $thdays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $fiveday)->where('listing_details.meta_value', '<=', $today)->get(array('meta_key AS value'))->count(); $sixdays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $tenday)->where('listing_details.meta_value', '<=', $fiveday)->get(array('meta_key AS value'))->count(); $nindays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $fifday)->where('listing_details.meta_value', '<=', $tenday)->get(array('meta_key AS value'))->count(); $twedays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $twentyday)->where('listing_details.meta_value', '<=', $fifday)->get(array('meta_key AS value'))->count(); $fifdays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $tfiveday)->where('listing_details.meta_value', '<=', $twentyday)->get(array('meta_key AS value'))->count(); $sevdays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $thurtyday)->where('listing_details.meta_value', '<=', $tfiveday)->get(array('meta_key AS value'))->count(); $twdays = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $id)->where('listing_details.meta_key', '=', 'phone_hits')->where('listing_details.meta_value', '>=', $thurtyfiveday)->where('listing_details.meta_value', '<=', $thurtyday)->get(array('meta_key AS value'))->count(); $one = $thdays['value']; $two = $sixdays['value']; $three = $nindays['value']; $four = $twedays['value']; $five = $fifdays['value']; $six = $sevdays['value']; $seven = $twdays['value']; if (empty($one)) { $one = '0'; } if (empty($two)) { $two = '0'; } if (empty($three)) { $three = '0'; } if (empty($four)) { $four = '0'; } if (empty($five)) { $five = '0'; } if (empty($six)) { $six = '0'; } if (empty($seven)) { $seven = '0'; } $phone_hits = "{ y: '7 days', a: " . $one . " },{ y: '14 days', a: " . $two . " },{ y: '21 days', a: " . $three . " },{ y: '28 days', a: " . $four . " },{ y: '35 days', a: " . $five . " },{ y: '42 days', a: " . $six . " },{ y: '49 days', a: " . $seven . " }"; $phone_hitsData['phone_hits'] = $phone_hits; return $phone_hitsData; }
public function searchlisting() { $json = Input::get('data.country_id'); $agent_id = Input::get('data.agent_id'); $meta_key = Input::get('data.meta_key'); $meta_value = Input::get('data.meta_value'); $values = explode(',', $json); if (empty($agent_id) || is_null($agent_id)) { return 'agent_ID should be blank'; } if (!empty($meta_key) && !is_null($meta_key)) { $searchmap['listing_details.meta_key'] = $meta_key; } if (!empty($meta_value) && !is_null($meta_value)) { $searchmap['listing_details.meta_value'] = $meta_value; } //if above array $searchmap is empty then it return all agents $price = listing::join('listing_details', 'post_id', '=', 'id')->where('listing.post_author', '=', $agent_id)->where($searchmap)->whereIn('cat_id', $values)->get(); $jsonVariable["TotalRecords"] = count($price); $jsonVariable["DATA"] = $price; return Response::json($jsonVariable); }