public function getCountryInterestDetails($id) { $var_cache = 'facebookCountryInterestDetails' . $id; //if (!Cache::has($var_cache)) { if (true) { $value = FacebookCountryInterest::whereId($id)->whereNivel(1)->first(); if (!$value) { return 'Invalid method'; } $id_interest = $value['id_interest']; $cache['name'] = $value['name']; $country = FacebookCountry::whereCode($value['country_code'])->first(['name', 'slug']); $cache['country']['name'] = $country['name']; $cache['country']['slug'] = $country['slug']; $cache['country']['code'] = strtolower($value['country_code']); $cache['chart_history'] = json_decode($value['chart_history'], true); $cache['key_metrics'] = array(); $cache['key_metrics'][] = $this->formatCityShortDetailsDataTableRow('Total', '', $value['total_user'], $value['total_user']); $cache['key_metrics'][] = $this->formatCityShortDetailsDataTableRow('Mujeres', '', $value['total_user'], $value['total_female']); $cache['key_metrics'][] = $this->formatCityShortDetailsDataTableRow('Hombres', '', $value['total_user'], $value['total_male']); /***** Interests *****/ $cache['list'] = array(); $interests = FacebookCountryInterest::whereCountryCode($value['country_code'])->whereNivelSuperior($id_interest)->orderBy('total_user', 'DESC')->get(['name', 'total_user', 'grow_7']); foreach ($interests as $interest) { $cache['list'][] = array('name' => $interest['name'], 'grow_7' => $this->formatGrow($interest['grow_7'], $interest['total_user']), 'total_user' => $this->owloo_number_format($interest['total_user'])); } Cache::put($var_cache, $cache, 1440); } return Cache::get($var_cache); }