Esempio n. 1
0
 public function getLastProfileAdded($idiom, $limit = 4)
 {
     $idiom = ucfirst($idiom);
     $var_cache = 'lastTwitterProfileAdded' . $idiom . $limit;
     if (!Cache::has($var_cache)) {
         $ranking = TwitterProfile::take($limit)->orderBy('id', 'DESC');
         switch ($idiom) {
             case 'All':
                 break;
             default:
                 $country_idiom = FacebookCountry::whereIdiom(strtolower($idiom))->first();
                 if ($country_idiom) {
                     $ranking->whereIdiom(strtolower($idiom));
                 } else {
                     return 'Invalid method';
                 }
         }
         $ranking = $ranking->get(['screen_name', 'name', 'picture']);
         $pages = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['screen_name'] = strtolower($value['screen_name']);
             $cache['name'] = $value['name'];
             $cache['picture'] = str_replace('_normal.', '.', $value['picture']);
             $pages[] = $cache;
         }
         Cache::put($var_cache, $pages, 1440);
     }
     return Cache::get($var_cache);
 }
Esempio n. 2
0
 public function getRankingProfileGrow($idiom)
 {
     $idiom = ucfirst($idiom);
     $var_cache = 'rankingGrowTwitterProfile' . $idiom;
     if (!Cache::has($var_cache)) {
         $ranking = TwitterProfile::take(4)->orderBy('followers_grow_30', 'DESC');
         switch ($idiom) {
             case 'All':
                 break;
             case 'Es':
                 $ranking->whereIdiom('es');
                 break;
                 /*case 'It':
                   $ranking->whereIdiom('it')->whereParent(0);
                   break;*/
             /*case 'It':
               $ranking->whereIdiom('it')->whereParent(0);
               break;*/
             default:
                 return 'Invalid method';
         }
         $ranking = $ranking->get(['screen_name', 'name', 'picture', 'followers_count', 'followers_grow_30']);
         $pages = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['screen_name'] = strtolower($value['screen_name']);
             $cache['name'] = $value['name'];
             $cache['picture'] = str_replace('_normal.', '.', $value['picture']);
             $cache['percent'] = 0;
             if ($value['followers_count'] - $value['followers_grow_30'] > 0) {
                 $cache['percent'] = $this->owlooFormatPorcent($value['followers_grow_30'], $value['followers_count'] - $value['followers_grow_30']);
             }
             $cache['grow_30'] = $this->owloo_number_format($value['followers_grow_30']);
             $pages[] = $cache;
         }
         Cache::put($var_cache, $pages, 1440);
     }
     return Cache::get($var_cache);
 }