Ejemplo 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);
 }
Ejemplo n.º 2
0
 public function getTotalCountries($where)
 {
     $var_cache = 'total' . ucfirst($where) . 'FacebookCountries';
     if (!Cache::has($var_cache)) {
         switch ($where) {
             case 'world':
                 $data['total'] = FacebookCountry::count();
                 break;
             case 'hispanic':
                 $data['total'] = FacebookCountry::whereIdiom('es')->count();
                 break;
             default:
                 return 'Invalid method';
         }
         Cache::put($var_cache, $data, 1440);
     }
     return Cache::get($var_cache);
 }
Ejemplo n.º 3
0
 public function getTotalRegions($where)
 {
     $where = strtolower($where);
     $var_cache = 'total' . ucfirst($where) . 'FacebookRegions';
     if (!Cache::has($var_cache)) {
         switch ($where) {
             case 'world':
                 $data['total'] = FacebookRegion::count();
                 break;
             case 'hispanic':
                 $data['total'] = FacebookRegion::whereIdiom('es')->count();
                 break;
             default:
                 $country_idiom = FacebookCountry::whereIdiom($where)->first();
                 if ($country_idiom) {
                     $data['total'] = FacebookRegion::whereIdiom($where)->count();
                 } else {
                     $country_search = FacebookCountry::whereCode(FacebookCountry::whereSlug($where)->first(['code'])->code)->first();
                     if ($country_search) {
                         $data['total'] = FacebookRegion::whereCountryCode($country_search->code)->count();
                     } else {
                         return 'Invalid method';
                     }
                 }
         }
         Cache::put($var_cache, $data, 1440);
     }
     return Cache::get($var_cache);
 }