public function getRankingCountryGrow($idiom)
 {
     $where = strtolower($idiom);
     $var_cache = 'rankingGrowCountry' . ucfirst($where);
     //if (!Cache::has($var_cache)) {
     if (true) {
         $ranking = FacebookCountry::take(4)->orderBy('audience_grow_90', 'DESC')->orderBy('total_user', 'DESC');
         switch ($where) {
             case 'all':
                 break;
             default:
                 $country_idiom = FacebookCountry::whereIdiom($where)->first();
                 if ($country_idiom) {
                     $ranking->whereIdiom($where);
                 } else {
                     return 'Invalid method';
                 }
         }
         $ranking = $ranking->get(['code', 'name', 'slug', 'abbreviation', 'total_user', 'audience_grow_90']);
         $countries = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['name'] = $value['name'];
             $cache['abbreviation'] = $value['abbreviation'];
             $cache['slug'] = $value['slug'];
             $cache['code'] = strtolower($value['code']);
             $cache['grow_90'] = $this->formatGrow($value['audience_grow_90'], $value['total_user']);
             $countries[] = $cache;
         }
         Cache::put($var_cache, $countries, 1440);
     }
     return Cache::get($var_cache);
 }
 public function getRankingCountryGrow($idiom)
 {
     $where = ucfirst($idiom);
     $var_cache = 'rankingGrowCountry' . $where;
     if (!Cache::has($var_cache)) {
         $ranking = FacebookCountry::take(4)->orderBy('audience_grow_30', 'DESC')->orderBy('total_user', 'DESC');
         switch ($where) {
             case 'All':
                 break;
             case 'Es':
                 $ranking->whereIdiom('es');
                 break;
                 /*case 'It':
                   $ranking->whereIdiom('it')->whereParent(0)->orWhereRaw('id_page = parent');
                   break;*/
             /*case 'It':
               $ranking->whereIdiom('it')->whereParent(0)->orWhereRaw('id_page = parent');
               break;*/
             default:
                 return 'Invalid method';
         }
         $ranking = $ranking->get(['code', 'name', 'name_en', 'abbreviation', 'total_user', 'audience_grow_30']);
         $countries = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['name'] = $value['name'];
             $cache['abbreviation'] = $value['abbreviation'];
             $cache['link'] = $this->convert_string_to_url($value['name_en']);
             $cache['code'] = strtolower($value['code']);
             $cache['grow_30'] = $this->formatGrow($value['audience_grow_30'], $value['total_user']);
             $countries[] = $cache;
         }
         Cache::put($var_cache, $countries, 1440);
     }
     return Cache::get($var_cache);
 }
 public function getRankingCountry($idiom, $page = 1)
 {
     $idiom = ucfirst($idiom);
     $var_cache = 'rankingCountries' . $idiom . '_' . ($page - 1) * 20;
     if (!Cache::has($var_cache)) {
         $ranking = FacebookCountry::take(20)->skip(($page - 1) * 20)->orderBy('total_user', 'DESC')->orderBy('audience_grow_30', 'DESC');
         switch ($idiom) {
             case 'World':
                 break;
             case 'Hispanic':
                 $ranking->whereIdiom('es');
                 break;
             default:
                 return 'Invalid method';
         }
         $ranking = $ranking->get(['code', 'name', 'name_en', 'abbreviation', 'total_user', 'total_female', 'total_male', 'audience_grow_90']);
         $countries = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['position'] = ($page - 1) * 20 + $key + 1;
             $cache['code'] = strtolower($value['code']);
             $cache['name'] = $value['name'];
             $cache['abbreviation'] = $value['abbreviation'];
             $cache['link'] = $this->convert_string_to_url($value['name_en']);
             $cache['total_user'] = $this->owloo_number_format($value['total_user']);
             $cache['total_female'] = array('value' => $this->owloo_number_format($value['total_female']), 'percent' => $this->owlooFormatPorcent($value['total_female'], $value['total_user']));
             $cache['total_male'] = array('value' => $this->owloo_number_format($value['total_male']), 'percent' => $this->owlooFormatPorcent($value['total_male'], $value['total_user']));
             $cache['grow_90'] = $this->formatGrow($value['audience_grow_90'], $value['total_user']);
             $countries[] = $cache;
         }
         Cache::put($var_cache, $countries, 1440);
     }
     return Cache::get($var_cache);
 }