public function selectagent() { $user_login = Input::get('data.user_login'); $user_pass = Input::get('data.user_pass'); $user_pass_hash = Input::get('data.user_pass_hash'); $user_pin = Input::get('data.user_pin'); $user_id = Input::get('data.user_id'); $country_id = Input::get('data.country_id'); $searchmap = null; if (!empty($user_login) && !is_null($user_login)) { $searchmap['user_login'] = $user_login; } if (!empty($user_pass) && !is_null($user_pass)) { $searchmap['user_pass'] = $user_pass; } if (!empty($user_pass_hash) && !is_null($user_pass_hash)) { $searchmap['user_pass_hash'] = $user_pass_hash; } if (!empty($user_pin) && !is_null($user_pin)) { $searchmap['user_pin'] = $user_pin; } if (!empty($user_id) && !is_null($user_id)) { $searchmap['ID'] = $user_id; } if (!empty($country_id) && !is_null($country_id)) { $searchmap['country_id'] = $country_id; } if (empty($searchmap) || is_null($searchmap)) { return '0'; } //if above array $searchmap is empty then it return all agents $agents = agents::where($searchmap)->get(); return $agents; }
public function CompetitorStats($id) { $jsonVariable; $usercity = agents::where('id', '=', $id)->pluck('postcode'); //get(array('postcode')); $jsonVariable["LoginAgentpostcode"] = $usercity; $sql = "select company_name competitor_company,"; $sql = $sql . " (Select count(*) from listing L where L.post_author=A.ID) competitor_property_count "; $sql = $sql . " from agents A where "; $sql = $sql . " A.ID != " . $id; $sql = $sql . " and A.postcode like '" . $usercity . "%' limit 10"; $competitor_list = DB::select(DB::raw($sql)); $competitor_count = count($competitor_list); $jsonVariable['COMPETITOR_COUNT'] = $competitor_count; $jsonVariable['COMPETITOR_DATA'] = $competitor_list; return $jsonVariable; }
public function loadLinkedTo() { $returnvalue = array(); // fk: fromagentid $t = new agents(); $t->load(getfromagentid()); $returnvalue[fromagentid] = $t; // fk: toagentid $t = new agents(); $t->load(gettoagentid()); $returnvalue[toagentid] = $t; return $returnvalue; }